waza_p.bin/waza_p2.bin File Format

From ProjectPokemon Wiki
Revision as of 21:46, 31 March 2015 by Psy commando (talk | contribs) (Created the waza_p.bin file format page.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


The "/BALANCE/waza_p.bin" file and the "/BALANCE/waza_p2.bin" files contains both the data for every moves in the game, and the movesets for every Pokemon in the game. Its a SIR0 wrapped format.

The "waza_p2.bin" file is found only in Explorers of Sky, and its purpose remains unknown. It contains mainly a perfect copy of all the move data in waza_p.bin. Only some Pokemon movesets differs between both files. Erasing the waza_p2.bin file from the game's files causes no immediate issues, as the game seems to use exclusively data from the waza_p.bin file inside and outside dungeons. The file is referred to in a string within the arm9.bin binary. Thus, it must be used eventually by the game in some way.

"waza" is the Romaji equivalent of "わざ", which means technique/art.[1]

File Structure

Overview

The format is pretty straightforward. Its made up of 3 major parts. The moveset data, the move data, and a table of pointers to regroup and access individual Pokemon moveset data.

Offset Length Name Description
0x00 16 SIR0 Header A SIR0 header wrapping the item data.
0x10 varies Movesets Data A block containing the moveset data for most Pokemon.
After Movesets Data 0-15 Padding Bytes Some 0xAA padding bytes to align the next block on 16 bytes.
After Padding Bytes varies Moves Data A block containing the data for all moves in the game.
After Moves Data 0-15 Padding Bytes Some 0xAA padding bytes to align the next section on 16 bytes.
After Padding Bytes varies Moveset Data Pointers Table A table containing pointers stored in groups of 3 for every Pokemon's moveset stored in there.
After Moveset Data Pointers Table 0-15 Padding Bytes Some 0xAA padding bytes to align the next section on 16 bytes.
After Padding Bytes 8 Waza Header Two pointers, one to the Moves Data, the other to the Moveset Data Pointers Table.
After Waza Header 0-15 Padding Bytes Some 0xAA padding bytes to align the next section on 16 bytes.
After Padding Bytes 3 SIR0 Pointer Offset List A list of encoded offsets to the pointers in the file. Since there are only the 2 pointers of the SIR0 header, those three bytes are always 0x04, 0x04, 0x00.
After SIR0 Pointer Offset List 13 Padding Bytes Since all entries have a fixed size, and the SIR0 Pointer Offset List is 3 bytes long, 13 0xAA bytes are used as padding to align the end of the file on 16 bytes.

Waza Header

Not really a header in the traditional sense, but more like the entry point to the data the file contains. Its made of two 4 bytes pointers, one to the beginning of the Moves Data block, and the other to the beginning of the Moveset Data Pointers Table.

Waza Header (Total length 8 bytes)
Offset Length Type Name Description
0x0 4 uint32 PtrMoveDataBlock Points to the beginning of the Moves Data block.
0x4 4 uint32 PtrPtrTable Points to the beginning of the Moveset Data Pointers Table.

Moves Data

This block is very simple. Its made up of 26 bytes entries containing data for all the moves used in the game. The first entry is always a dummy move. The order the moves appears in this block is the same order as the move names strings are stored inside the text*.str file. The same goes for the moves' description strings.


Move Data Entry (Total length 26 bytes)
Offset Length Type Name Description
0x00 2 uint16 Base Power The base power of the move.
0x02 1 uint8 Type The type of the move. See the types list below, for the possible values.
0x03 1 uint8 Category What kind of move is it.
  • 0x0 is Physical
  • 0x1 is Special
  • 0x2 is Status move
0x04 2 uint16 Bitfield#1 A bit field not fully understood yet. It does however changes what enemies are hit at close range. See Bitfield 1 for more details.
0x06 2 uint16 Bitfield#2 Another bit field that's not fully understood yet. This one seems to alter long-range attack. See Bitfield 2 for more details.
0x08 1 uint8 Base PPs The base amount of PP for the move.
0x09 1 uint8 Unk#6 Unknown.
0x0A 1 uint8 Unk#7 Unknown.
0x0B 1 uint8 Move Accuracy The percentage indicating the chances the move will succeed. 100 is perfect accuracy. Anything higher than 100 is a never-miss move.
0x0C 1 uint8 Unk#9 Unknown.
0x0D 1 uint8 Unk#10 Unknown.
0x0E 1 uint8 Unk#11 Unknown.
0x0F 1 uint8 Unk#12 Unknown. Possibly related to critical hits calculation?
0x10 1 uint8 Unk#13 Unknown.
0x11 1 uint8 Unk#14 Unknown.
0x12 1 uint8 Unk#15 Unknown.
0x13 1 uint8 Unk#16 Unknown.
0x14 1 uint8 Unk#17 Unknown.
0x15 1 uint8 Unk#18 Unknown. Possible bitfield.
0x16 2 uint16 Move ID The move's ID, possibly used by the game code for allocating resources and etc..
0x18 1 uint8 Unk#19 Unknown.

Types List

Value Type
0x00 None
0x01 Normal
0x02 Fire
0x03 Water
0x04 Grass
0x05 Electric
0x06 Ice
0x07 Fighting
0x08 Poison
0x09 Ground
0x0A Flying
0x0B Psychic
0x0C Bug
0x0D Rock
0x0E Ghost
0x0F Dragon
0x10 Dark
0x11 Steel
0x12 Neutral

Bitfield 1

Not much is known about this field, except that setting some of its bits to 1 changes the way moves target entities.

0001 0000 (16)= Hit everything next to the user on 180 degrees forward 
0010 0000(32) = Hit everything next to the user on 360 degrees
0011 0000(48) = Hit everything in the same room
0111 0011(115)= Hit user

Bitfield 2

Not much either is known about this field. Changing some of its bits seems to alter ranged moves.

0101 0000(80) makes the move a long range straight line attack 

Moveset Data Pointers Table

A table made of a series of groups of 3 pointers. Each groups of 3 pointers is assigned to a Pokemon that has the same index in monster.md as the group of pointer.

Moveset Pointers Group (Total length 12 bytes)
Offset Length Type Name Description
0x0 4 uint32 PtrLvlUpLst Points to this Pokemon's level-up moves list. Only null for the first dummy Pokemon.
0x4 4 uint32 PtrHmTmLst Points to this Pokemon's list of teachable HM/TM moves. Only null for the first dummy Pokemon.
0x8 4 uint32 PtrEggLst Points to this Pokemon's list of possible egg moves. Only null for the first dummy Pokemon.

Movesets Data

This block is made of null terminated lists of encoded integers. Each lists are pointed to by a pointer in the Moveset Data Pointers Table.

The block always begin with 3 null bytes. Those are the lists for the dummy first Pokemon.

Every 3 lists belongs to a specific Pokemon, and each have a specific content/purpose. An empty list is represented by a single null byte.

Moveset Lists Group
Offset Name Description
0x0 Level-Up Moves List This list of integer is particular. Its not just a list of moves, like the two others. Each move ID is followed with the level at which the Pokemon learns the move. So essentially, every 2 integer decoded from this list form a pair indicating the move ID and then the level.
After Level-Up Moves List HM/TM Moves List A simple list of integer where each value correspond to a HM/TMs move ID the Pokemon can learn.
After HM/TM Moves List Egg Moves List Another simple list of integer where each value correspond to a move ID of a move the Pokemon may get if it hatches from an egg.

Encoding

The encoding for the lists is the same used for the SIR0 format's encoded pointer list. However, each values decoded is not relative to the previous one, and you must keep in mind that there are several lists, not a single one, unlike the SIR0's encoded pointer offsets list. Also, the move IDs are 16 bits integers, not 32 bits integers like the pointer offsets are.

Here's an example of decoding Bulbasaur's 3 lists. This only shows the raw bytes, then the decoded raw values, then the corresponding move to the move ID that was decoded:

   First List:
   0x81 0x1A 0x01    => 0x9A,   1  => Tackle         lvl  1
   0x81 0x59 0x03    => 0xD9,   3  => Growl          lvl  3
   0x82 0x49 0x07    => 0x149,  7  => Leech Seed     lvl  7
   0x81 0x36 0x09    => 0xB6,   9  => Vine Whip      lvl  9
   0x81 0x47 0x0D    => 0xC7,  13  => Poison Powder  lvl 13
   0x81 0x67 0x0D    => 0xE7,  13  => Sleep Powder   lvl 13
   0x81 0x4B 0x0F    => 0xCB,  15  => Take Down      lvl 15
   0x81 0x7B 0x13    => 0xFB,  19  => Razor Leaf     lvl 19
   0x0A 0x15         => 0x0A,  21  => Sweet Scent    lvl 21
   0x81 0x14 0x19    => 0x94,  25  => Growth         lvl 25
   0x81 0x0C 0x1B    => 0x8C,  27  => Double-Edge    lvl 27
   0x83 0x78 0x1F    => 0x1F8, 31  => Worry Seed     lvl 31
   0x5E 0x21         => 0x5E,  33  => Synthesis      lvl 33
   0x83 0x66 0x25    => 0x1E6, 37  => Seed Bomb      lvl 37
   0x00
   
   Second List:
   0x12        => 18         => Cut
   0x18        => 24         => Swagger
   0x1D        => 29         => Rock Smash
   0x30        => 48         => Return
   0x32        => 50         => Strength
   0x38        => 56         => Double Team
   0x43        => 67         => Facade
   0x4C        => 76         => Giga-Drain
   0x68        => 104        => Endure
   0x81 0x17   => 151        => Solar Beam
   0x81 0x23   => 163        => Bullet Seed
   0x81 0x35   => 181        => Swords Dance
   0x81 0x45   => 197        => Toxic
   0x81 0x5F   => 223        => Sunny Day 
   0x81 0x63   => 227        => Sleep Talk
   0x81 0x68   => 232        => Rest
   0x82 0x07   => 263        => Secret Power
   0x82 0x11   => 273        => Flash
   0x82 0x18   => 280        => Sludge Bomb
   0x82 0x2D   => 301        => Protect
   0x82 0x30   => 304        => Substitute
   0x82 0x44   => 324        => Hidden Power
   0x82 0x46   => 326        => Attract
   0x82 0x48   => 328        => Frustration
   0x82 0x68   => 360        => Wide Slash
   0x83 0x0A   => 394        => Vacuum-Cut
   0x83 0x3B   => 443        => Energy Ball
   0x83 0x4A   => 458        => Grass Knot
   0x83 0x57   => 471        => Natural Gift
   0x84 0x16   => 534        => Captivate
   0x00 
   
   Third List:
   0x0B        => 11         => Charm
   0x54        => 84         => Grass Whistle
   0x77        => 119        => Nature Power
   0x81 0x06   => 134        => Safeguard
   0x81 0x57   => 215        => Amnesia
   0x81 0x69   => 233        => Ingrain
   0x81 0x6D   => 237        => Curse
   0x81 0x7D   => 253        => Petal Dance
   0x82 0x03   => 259        => Light Screen
   0x82 0x29   => 297        => Magical Leaf
   0x82 0x5C   => 348        => Skull Bash
   0x84 0x19   => 537        => Leaf Storm
   0x00 


Credits

  • The WMS project, for their notes. [2]
  • OgreGunner and nhahtdh for that huge thread on GameFaqs filled with tidbits of information! [3]
  • Kelvin Chung for the .grammar file containing much useful information on the PMD:RRT format, which share similarities with PMD2! [4]