pokeemerald/src/pokemon_icon.c

1319 lines
28 KiB
C
Raw Normal View History

2017-12-22 19:16:15 +01:00
#include "global.h"
#include "graphics.h"
2018-11-14 01:01:50 +01:00
#include "mail.h"
2018-04-13 14:21:49 +02:00
#include "palette.h"
#include "pokemon_icon.h"
2018-11-14 01:01:50 +01:00
#include "sprite.h"
#include "constants/species.h"
2017-12-22 19:16:15 +01:00
#define POKE_ICON_BASE_PAL_TAG 56000
2018-04-13 14:21:49 +02:00
struct MonIconSpriteTemplate
{
const struct OamData *oam;
const u8 *image;
const union AnimCmd *const *anims;
const union AffineAnimCmd *const *affineAnims;
void (*callback)(struct Sprite *);
u16 paletteTag;
};
// static functions
static u8 CreateMonIconSprite(struct MonIconSpriteTemplate *, s16, s16, u8);
// .rodata
2018-10-21 09:24:57 +02:00
const u8 *const gMonIconTable[] =
2017-12-22 19:16:15 +01:00
{
gMonIcon_Bulbasaur,
gMonIcon_Bulbasaur,
gMonIcon_Ivysaur,
gMonIcon_Venusaur,
gMonIcon_Charmander,
gMonIcon_Charmeleon,
gMonIcon_Charizard,
gMonIcon_Squirtle,
gMonIcon_Wartortle,
gMonIcon_Blastoise,
gMonIcon_Caterpie,
gMonIcon_Metapod,
gMonIcon_Butterfree,
gMonIcon_Weedle,
gMonIcon_Kakuna,
gMonIcon_Beedrill,
gMonIcon_Pidgey,
gMonIcon_Pidgeotto,
gMonIcon_Pidgeot,
gMonIcon_Rattata,
gMonIcon_Raticate,
gMonIcon_Spearow,
gMonIcon_Fearow,
gMonIcon_Ekans,
gMonIcon_Arbok,
gMonIcon_Pikachu,
gMonIcon_Raichu,
gMonIcon_Sandshrew,
gMonIcon_Sandslash,
gMonIcon_NidoranF,
gMonIcon_Nidorina,
gMonIcon_Nidoqueen,
gMonIcon_NidoranM,
gMonIcon_Nidorino,
gMonIcon_Nidoking,
gMonIcon_Clefairy,
gMonIcon_Clefable,
gMonIcon_Vulpix,
gMonIcon_Ninetales,
gMonIcon_Jigglypuff,
gMonIcon_Wigglytuff,
gMonIcon_Zubat,
gMonIcon_Golbat,
gMonIcon_Oddish,
gMonIcon_Gloom,
gMonIcon_Vileplume,
gMonIcon_Paras,
gMonIcon_Parasect,
gMonIcon_Venonat,
gMonIcon_Venomoth,
gMonIcon_Diglett,
gMonIcon_Dugtrio,
gMonIcon_Meowth,
gMonIcon_Persian,
gMonIcon_Psyduck,
gMonIcon_Golduck,
gMonIcon_Mankey,
gMonIcon_Primeape,
gMonIcon_Growlithe,
gMonIcon_Arcanine,
gMonIcon_Poliwag,
gMonIcon_Poliwhirl,
gMonIcon_Poliwrath,
gMonIcon_Abra,
gMonIcon_Kadabra,
gMonIcon_Alakazam,
gMonIcon_Machop,
gMonIcon_Machoke,
gMonIcon_Machamp,
gMonIcon_Bellsprout,
gMonIcon_Weepinbell,
gMonIcon_Victreebel,
gMonIcon_Tentacool,
gMonIcon_Tentacruel,
gMonIcon_Geodude,
gMonIcon_Graveler,
gMonIcon_Golem,
gMonIcon_Ponyta,
gMonIcon_Rapidash,
gMonIcon_Slowpoke,
gMonIcon_Slowbro,
gMonIcon_Magnemite,
gMonIcon_Magneton,
gMonIcon_Farfetchd,
gMonIcon_Doduo,
gMonIcon_Dodrio,
gMonIcon_Seel,
gMonIcon_Dewgong,
gMonIcon_Grimer,
gMonIcon_Muk,
gMonIcon_Shellder,
gMonIcon_Cloyster,
gMonIcon_Gastly,
gMonIcon_Haunter,
gMonIcon_Gengar,
gMonIcon_Onix,
gMonIcon_Drowzee,
gMonIcon_Hypno,
gMonIcon_Krabby,
gMonIcon_Kingler,
gMonIcon_Voltorb,
gMonIcon_Electrode,
gMonIcon_Exeggcute,
gMonIcon_Exeggutor,
gMonIcon_Cubone,
gMonIcon_Marowak,
gMonIcon_Hitmonlee,
gMonIcon_Hitmonchan,
gMonIcon_Lickitung,
gMonIcon_Koffing,
gMonIcon_Weezing,
gMonIcon_Rhyhorn,
gMonIcon_Rhydon,
gMonIcon_Chansey,
gMonIcon_Tangela,
gMonIcon_Kangaskhan,
gMonIcon_Horsea,
gMonIcon_Seadra,
gMonIcon_Goldeen,
gMonIcon_Seaking,
gMonIcon_Staryu,
gMonIcon_Starmie,
gMonIcon_Mrmime,
gMonIcon_Scyther,
gMonIcon_Jynx,
gMonIcon_Electabuzz,
gMonIcon_Magmar,
gMonIcon_Pinsir,
gMonIcon_Tauros,
gMonIcon_Magikarp,
gMonIcon_Gyarados,
gMonIcon_Lapras,
gMonIcon_Ditto,
gMonIcon_Eevee,
gMonIcon_Vaporeon,
gMonIcon_Jolteon,
gMonIcon_Flareon,
gMonIcon_Porygon,
gMonIcon_Omanyte,
gMonIcon_Omastar,
gMonIcon_Kabuto,
gMonIcon_Kabutops,
gMonIcon_Aerodactyl,
gMonIcon_Snorlax,
gMonIcon_Articuno,
gMonIcon_Zapdos,
gMonIcon_Moltres,
gMonIcon_Dratini,
gMonIcon_Dragonair,
gMonIcon_Dragonite,
gMonIcon_Mewtwo,
gMonIcon_Mew,
gMonIcon_Chikorita,
gMonIcon_Bayleef,
gMonIcon_Meganium,
gMonIcon_Cyndaquil,
gMonIcon_Quilava,
gMonIcon_Typhlosion,
gMonIcon_Totodile,
gMonIcon_Croconaw,
gMonIcon_Feraligatr,
gMonIcon_Sentret,
gMonIcon_Furret,
gMonIcon_Hoothoot,
gMonIcon_Noctowl,
gMonIcon_Ledyba,
gMonIcon_Ledian,
gMonIcon_Spinarak,
gMonIcon_Ariados,
gMonIcon_Crobat,
gMonIcon_Chinchou,
gMonIcon_Lanturn,
gMonIcon_Pichu,
gMonIcon_Cleffa,
gMonIcon_Igglybuff,
gMonIcon_Togepi,
gMonIcon_Togetic,
gMonIcon_Natu,
gMonIcon_Xatu,
gMonIcon_Mareep,
gMonIcon_Flaaffy,
gMonIcon_Ampharos,
gMonIcon_Bellossom,
gMonIcon_Marill,
gMonIcon_Azumarill,
gMonIcon_Sudowoodo,
gMonIcon_Politoed,
gMonIcon_Hoppip,
gMonIcon_Skiploom,
gMonIcon_Jumpluff,
gMonIcon_Aipom,
gMonIcon_Sunkern,
gMonIcon_Sunflora,
gMonIcon_Yanma,
gMonIcon_Wooper,
gMonIcon_Quagsire,
gMonIcon_Espeon,
gMonIcon_Umbreon,
gMonIcon_Murkrow,
gMonIcon_Slowking,
gMonIcon_Misdreavus,
gMonIcon_UnownA,
gMonIcon_Wobbuffet,
gMonIcon_Girafarig,
gMonIcon_Pineco,
gMonIcon_Forretress,
gMonIcon_Dunsparce,
gMonIcon_Gligar,
gMonIcon_Steelix,
gMonIcon_Snubbull,
gMonIcon_Granbull,
gMonIcon_Qwilfish,
gMonIcon_Scizor,
gMonIcon_Shuckle,
gMonIcon_Heracross,
gMonIcon_Sneasel,
gMonIcon_Teddiursa,
gMonIcon_Ursaring,
gMonIcon_Slugma,
gMonIcon_Magcargo,
gMonIcon_Swinub,
gMonIcon_Piloswine,
gMonIcon_Corsola,
gMonIcon_Remoraid,
gMonIcon_Octillery,
gMonIcon_Delibird,
gMonIcon_Mantine,
gMonIcon_Skarmory,
gMonIcon_Houndour,
gMonIcon_Houndoom,
gMonIcon_Kingdra,
gMonIcon_Phanpy,
gMonIcon_Donphan,
gMonIcon_Porygon2,
gMonIcon_Stantler,
gMonIcon_Smeargle,
gMonIcon_Tyrogue,
gMonIcon_Hitmontop,
gMonIcon_Smoochum,
gMonIcon_Elekid,
gMonIcon_Magby,
gMonIcon_Miltank,
gMonIcon_Blissey,
gMonIcon_Raikou,
gMonIcon_Entei,
gMonIcon_Suicune,
gMonIcon_Larvitar,
gMonIcon_Pupitar,
gMonIcon_Tyranitar,
gMonIcon_Lugia,
gMonIcon_HoOh,
gMonIcon_Celebi,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_QuestionMark,
gMonIcon_Treecko,
gMonIcon_Grovyle,
gMonIcon_Sceptile,
gMonIcon_Torchic,
gMonIcon_Combusken,
gMonIcon_Blaziken,
gMonIcon_Mudkip,
gMonIcon_Marshtomp,
gMonIcon_Swampert,
gMonIcon_Poochyena,
gMonIcon_Mightyena,
gMonIcon_Zigzagoon,
gMonIcon_Linoone,
gMonIcon_Wurmple,
gMonIcon_Silcoon,
gMonIcon_Beautifly,
gMonIcon_Cascoon,
gMonIcon_Dustox,
gMonIcon_Lotad,
gMonIcon_Lombre,
gMonIcon_Ludicolo,
gMonIcon_Seedot,
gMonIcon_Nuzleaf,
gMonIcon_Shiftry,
gMonIcon_Nincada,
gMonIcon_Ninjask,
gMonIcon_Shedinja,
gMonIcon_Taillow,
gMonIcon_Swellow,
gMonIcon_Shroomish,
gMonIcon_Breloom,
gMonIcon_Spinda,
gMonIcon_Wingull,
gMonIcon_Pelipper,
gMonIcon_Surskit,
gMonIcon_Masquerain,
gMonIcon_Wailmer,
gMonIcon_Wailord,
gMonIcon_Skitty,
gMonIcon_Delcatty,
gMonIcon_Kecleon,
gMonIcon_Baltoy,
gMonIcon_Claydol,
gMonIcon_Nosepass,
gMonIcon_Torkoal,
gMonIcon_Sableye,
gMonIcon_Barboach,
gMonIcon_Whiscash,
gMonIcon_Luvdisc,
gMonIcon_Corphish,
gMonIcon_Crawdaunt,
gMonIcon_Feebas,
gMonIcon_Milotic,
gMonIcon_Carvanha,
gMonIcon_Sharpedo,
gMonIcon_Trapinch,
gMonIcon_Vibrava,
gMonIcon_Flygon,
gMonIcon_Makuhita,
gMonIcon_Hariyama,
gMonIcon_Electrike,
gMonIcon_Manectric,
gMonIcon_Numel,
gMonIcon_Camerupt,
gMonIcon_Spheal,
gMonIcon_Sealeo,
gMonIcon_Walrein,
gMonIcon_Cacnea,
gMonIcon_Cacturne,
gMonIcon_Snorunt,
gMonIcon_Glalie,
gMonIcon_Lunatone,
gMonIcon_Solrock,
gMonIcon_Azurill,
gMonIcon_Spoink,
gMonIcon_Grumpig,
gMonIcon_Plusle,
gMonIcon_Minun,
gMonIcon_Mawile,
gMonIcon_Meditite,
gMonIcon_Medicham,
gMonIcon_Swablu,
gMonIcon_Altaria,
gMonIcon_Wynaut,
gMonIcon_Duskull,
gMonIcon_Dusclops,
gMonIcon_Roselia,
gMonIcon_Slakoth,
gMonIcon_Vigoroth,
gMonIcon_Slaking,
gMonIcon_Gulpin,
gMonIcon_Swalot,
gMonIcon_Tropius,
gMonIcon_Whismur,
gMonIcon_Loudred,
gMonIcon_Exploud,
gMonIcon_Clamperl,
gMonIcon_Huntail,
gMonIcon_Gorebyss,
gMonIcon_Absol,
gMonIcon_Shuppet,
gMonIcon_Banette,
gMonIcon_Seviper,
gMonIcon_Zangoose,
gMonIcon_Relicanth,
gMonIcon_Aron,
gMonIcon_Lairon,
gMonIcon_Aggron,
gMonIcon_Castform,
gMonIcon_Volbeat,
gMonIcon_Illumise,
gMonIcon_Lileep,
gMonIcon_Cradily,
gMonIcon_Anorith,
gMonIcon_Armaldo,
gMonIcon_Ralts,
gMonIcon_Kirlia,
gMonIcon_Gardevoir,
gMonIcon_Bagon,
gMonIcon_Shelgon,
gMonIcon_Salamence,
gMonIcon_Beldum,
gMonIcon_Metang,
gMonIcon_Metagross,
gMonIcon_Regirock,
gMonIcon_Regice,
gMonIcon_Registeel,
gMonIcon_Kyogre,
gMonIcon_Groudon,
gMonIcon_Rayquaza,
gMonIcon_Latias,
gMonIcon_Latios,
gMonIcon_Jirachi,
gMonIcon_Deoxys,
gMonIcon_Chimecho,
gMonIcon_Egg,
gMonIcon_UnownB,
gMonIcon_UnownC,
gMonIcon_UnownD,
gMonIcon_UnownE,
gMonIcon_UnownF,
gMonIcon_UnownG,
gMonIcon_UnownH,
gMonIcon_UnownI,
gMonIcon_UnownJ,
gMonIcon_UnownK,
gMonIcon_UnownL,
gMonIcon_UnownM,
gMonIcon_UnownN,
gMonIcon_UnownO,
gMonIcon_UnownP,
gMonIcon_UnownQ,
gMonIcon_UnownR,
gMonIcon_UnownS,
gMonIcon_UnownT,
gMonIcon_UnownU,
gMonIcon_UnownV,
gMonIcon_UnownW,
gMonIcon_UnownX,
gMonIcon_UnownY,
gMonIcon_UnownZ,
gMonIcon_UnownExclamationMark,
gMonIcon_UnownQuestionMark,
};
const u8 gMonIconPaletteIndices[] =
{
0, // ??????????
1, // Bulbasaur
1, // Ivysaur
1, // Venusaur
0, // Charmander
0, // Charmeleon
0, // Charizard
0, // Squirtle
2, // Wartortle
2, // Blastoise
1, // Caterpie
1, // Metapod
0, // Butterfree
1, // Weedle
2, // Kakuna
2, // Beedrill
0, // Pidgey
0, // Pidgeotto
0, // Pidgeot
2, // Rattata
1, // Raticate
0, // Spearow
0, // Fearow
2, // Ekans
2, // Arbok
2, // Pikachu
0, // Raichu
2, // Sandshrew
2, // Sandslash
2, // Nidoran♀
2, // Nidorina
2, // Nidoqueen
2, // Nidoran♂
2, // Nidorino
2, // Nidoking
0, // Clefairy
0, // Clefable
2, // Vulpix
1, // Ninetales
0, // Jigglypuff
0, // Wigglytuff
2, // Zubat
2, // Golbat
1, // Oddish
0, // Gloom
0, // Vileplume
0, // Paras
0, // Parasect
0, // Venonat
2, // Venomoth
2, // Diglett
2, // Dugtrio
1, // Meowth
1, // Persian
1, // Psyduck
2, // Golduck
1, // Mankey
2, // Primeape
0, // Growlithe
0, // Arcanine
0, // Poliwag
0, // Poliwhirl
0, // Poliwrath
2, // Abra
2, // Kadabra
2, // Alakazam
0, // Machop
2, // Machoke
0, // Machamp
1, // Bellsprout
1, // Weepinbell
1, // Victreebel
2, // Tentacool
2, // Tentacruel
1, // Geodude
1, // Graveler
1, // Golem
0, // Ponyta
0, // Rapidash
0, // Slowpoke
0, // Slowbro
0, // Magnemite
0, // Magneton
1, // Farfetch'd
2, // Doduo
2, // Dodrio
2, // Seel
2, // Dewgong
2, // Grimer
2, // Muk
2, // Shellder
2, // Cloyster
2, // Gastly
2, // Haunter
2, // Gengar
2, // Onix
2, // Drowzee
1, // Hypno
2, // Krabby
2, // Kingler
0, // Voltorb
0, // Electrode
0, // Exeggcute
1, // Exeggutor
1, // Cubone
1, // Marowak
2, // Hitmonlee
2, // Hitmonchan
1, // Lickitung
2, // Koffing
2, // Weezing
1, // Rhyhorn
1, // Rhydon
0, // Chansey
0, // Tangela
1, // Kangaskhan
0, // Horsea
0, // Seadra
0, // Goldeen
0, // Seaking
2, // Staryu
2, // Starmie
0, // Mr. mime
1, // Scyther
2, // Jynx
1, // Electabuzz
0, // Magmar
2, // Pinsir
2, // Tauros
0, // Magikarp
0, // Gyarados
2, // Lapras
2, // Ditto
2, // Eevee
0, // Vaporeon
0, // Jolteon
0, // Flareon
0, // Porygon
0, // Omanyte
0, // Omastar
2, // Kabuto
2, // Kabutops
0, // Aerodactyl
1, // Snorlax
0, // Articuno
0, // Zapdos
0, // Moltres
0, // Dratini
0, // Dragonair
2, // Dragonite
2, // Mewtwo
0, // Mew
1, // Chikorita
1, // Bayleef
1, // Meganium
1, // Cyndaquil
1, // Quilava
1, // Typhlosion
2, // Totodile
2, // Croconaw
2, // Feraligatr
2, // Sentret
2, // Furret
2, // Hoothoot
2, // Noctowl
0, // Ledyba
0, // Ledian
1, // Spinarak
0, // Ariados
2, // Crobat
2, // Chinchou
0, // Lanturn
0, // Pichu
0, // Cleffa
1, // Igglybuff
2, // Togepi
2, // Togetic
0, // Natu
0, // Xatu
2, // Mareep
0, // Flaaffy
0, // Ampharos
1, // Bellossom
2, // Marill
2, // Azumarill
1, // Sudowoodo
1, // Politoed
1, // Hoppip
1, // Skiploom
2, // Jumpluff
2, // Aipom
1, // Sunkern
1, // Sunflora
1, // Yanma
0, // Wooper
0, // Quagsire
2, // Espeon
2, // Umbreon
2, // Murkrow
0, // Slowking
0, // Misdreavus
0, // Unown A
0, // Wobbuffet
1, // Girafarig
0, // Pineco
2, // Forretress
2, // Dunsparce
2, // Gligar
0, // Steelix
0, // Snubbull
2, // Granbull
0, // Qwilfish
0, // Scizor
1, // Shuckle
2, // Heracross
0, // Sneasel
0, // Teddiursa
2, // Ursaring
0, // Slugma
0, // Magcargo
2, // Swinub
2, // Piloswine
0, // Corsola
0, // Remoraid
0, // Octillery
0, // Delibird
2, // Mantine
0, // Skarmory
0, // Houndour
0, // Houndoom
0, // Kingdra
0, // Phanpy
0, // Donphan
0, // Porygon2
2, // Stantler
1, // Smeargle
2, // Tyrogue
2, // Hitmontop
1, // Smoochum
1, // Elekid
1, // Magby
1, // Miltank
1, // Blissey
0, // Raikou
2, // Entei
0, // Suicune
1, // Larvitar
0, // Pupitar
1, // Tyranitar
0, // Lugia
1, // Ho-Oh
1, // Celebi
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
0, // ?
1, // Treecko
0, // Grovyle
1, // Sceptile
0, // Torchic
0, // Combusken
0, // Blaziken
0, // Mudkip
0, // Marshtomp
0, // Swampert
2, // Poochyena
2, // Mightyena
2, // Zigzagoon
2, // Linoone
0, // Wurmple
2, // Silcoon
0, // Beautifly
2, // Cascoon
1, // Dustox
1, // Lotad
1, // Lombre
1, // Ludicolo
1, // Seedot
1, // Nuzleaf
0, // Shiftry
1, // Nincada
1, // Ninjask
1, // Shedinja
2, // Taillow
2, // Swellow
1, // Shroomish
1, // Breloom
1, // Spinda
0, // Wingull
0, // Pelipper
2, // Surskit
0, // Masquerain
2, // Wailmer
0, // Wailord
0, // Skitty
2, // Delcatty
1, // Kecleon
1, // Baltoy
0, // Claydol
0, // Nosepass
1, // Torkoal
2, // Sableye
0, // Barboach
0, // Whiscash
0, // Luvdisc
0, // Corphish
0, // Crawdaunt
2, // Feebas
0, // Milotic
0, // Carvanha
0, // Sharpedo
1, // Trapinch
1, // Vibrava
1, // Flygon
2, // Makuhita
1, // Hariyama
1, // Electrike
0, // Manectric
1, // Numel
0, // Camerupt
2, // Spheal
2, // Sealeo
0, // Walrein
1, // Cacnea
1, // Cacturne
2, // Snorunt
0, // Glalie
1, // Lunatone
0, // Solrock
2, // Azurill
0, // Spoink
2, // Grumpig
0, // Plusle
0, // Minun
2, // Mawile
0, // Meditite
0, // Medicham
0, // Swablu
0, // Altaria
0, // Wynaut
0, // Duskull
0, // Dusclops
0, // Roselia
2, // Slakoth
2, // Vigoroth
1, // Slaking
1, // Gulpin
2, // Swalot
1, // Tropius
0, // Whismur
2, // Loudred
2, // Exploud
0, // Clamperl
0, // Huntail
0, // Gorebyss
0, // Absol
0, // Shuppet
0, // Banette
2, // Seviper
0, // Zangoose
1, // Relicanth
2, // Aron
2, // Lairon
2, // Aggron
0, // Castform
0, // Volbeat
2, // Illumise
2, // Lileep
0, // Cradily
0, // Anorith
0, // Armaldo
1, // Ralts
1, // Kirlia
1, // Gardevoir
2, // Bagon
2, // Shelgon
0, // Salamence
0, // Beldum
0, // Metang
0, // Metagross
2, // Regirock
2, // Regice
2, // Registeel
2, // Kyogre
0, // Groudon
1, // Rayquaza
0, // Latias
2, // Latios
0, // Jirachi
0, // Deoxys
0, // Chimecho
1, // Egg
0, // Unown B
0, // Unown C
0, // Unown D
0, // Unown E
0, // Unown F
0, // Unown G
0, // Unown H
0, // Unown I
0, // Unown J
0, // Unown K
0, // Unown L
0, // Unown M
0, // Unown N
0, // Unown O
0, // Unown P
0, // Unown Q
0, // Unown R
0, // Unown S
0, // Unown T
0, // Unown U
0, // Unown V
0, // Unown W
0, // Unown X
0, // Unown Y
0, // Unown Z
0, // Unown Exclamation Mark
0, // Unown Question Mark
};
const struct SpritePalette gMonIconPaletteTable[] =
{
{ gMonIconPalettes[0], POKE_ICON_BASE_PAL_TAG + 0 },
{ gMonIconPalettes[1], POKE_ICON_BASE_PAL_TAG + 1 },
{ gMonIconPalettes[2], POKE_ICON_BASE_PAL_TAG + 2 },
// There are only 3 actual palettes. The following are unused
// and don't point to valid data.
{ gMonIconPalettes[3], POKE_ICON_BASE_PAL_TAG + 3 },
{ gMonIconPalettes[4], POKE_ICON_BASE_PAL_TAG + 4 },
{ gMonIconPalettes[5], POKE_ICON_BASE_PAL_TAG + 5 },
};
const struct OamData sMonIconOamData =
{
.y = 0,
.affineMode = 0,
.objMode = 0,
.mosaic = 0,
.bpp = 0,
.shape = 0,
.x = 0,
.matrixNum = 0,
.size = 2,
.tileNum = 0,
.priority = 1,
.paletteNum = 0,
.affineParam = 0
};
// fastest to slowest
static const union AnimCmd sAnim_0[] =
{
ANIMCMD_FRAME(0, 6),
ANIMCMD_FRAME(1, 6),
ANIMCMD_JUMP(0),
};
static const union AnimCmd sAnim_1[] =
{
ANIMCMD_FRAME(0, 8),
ANIMCMD_FRAME(1, 8),
ANIMCMD_JUMP(0),
};
static const union AnimCmd sAnim_2[] =
{
ANIMCMD_FRAME(0, 14),
ANIMCMD_FRAME(1, 14),
ANIMCMD_JUMP(0),
};
static const union AnimCmd sAnim_3[] =
{
ANIMCMD_FRAME(0, 22),
ANIMCMD_FRAME(1, 22),
ANIMCMD_JUMP(0),
};
static const union AnimCmd sAnim_4[] =
{
ANIMCMD_FRAME(0, 29),
ANIMCMD_FRAME(0, 29), // frame 0 is repeated
ANIMCMD_JUMP(0),
};
const union AnimCmd *const sMonIconAnims[] =
{
sAnim_0,
sAnim_1,
sAnim_2,
sAnim_3,
sAnim_4,
};
static const union AffineAnimCmd sAffineAnim_0[] =
{
AFFINEANIMCMD_FRAME(0, 0, 0, 10),
AFFINEANIMCMD_END,
};
static const union AffineAnimCmd sAffineAnim_1[] =
{
AFFINEANIMCMD_FRAME(-2, -2, 0, 122),
AFFINEANIMCMD_END,
};
const union AffineAnimCmd *const sMonIconAffineAnims[] =
{
sAffineAnim_0,
sAffineAnim_1,
};
const u16 sSpriteImageSizes[3][4] =
{
// square
{
0x20, // 1×1
0x80, // 2×2
0x200, // 4×4
0x800, // 8×8
},
// horizontal rectangle
{
0x40, // 2×1
0x80, // 4×1
0x100, // 4×2
0x400, // 8×4
},
// vertical rectangle
{
0x40, // 1×2
0x80, // 1×4
0x100, // 2×4
0x400, // 4×8
},
};
2018-04-13 14:21:49 +02:00
u8 CreateMonIcon(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority, u32 personality, bool32 extra)
{
u8 spriteId;
struct MonIconSpriteTemplate iconTemplate =
{
.oam = &sMonIconOamData,
.image = GetMonIconPtr(species, personality, extra),
.anims = sMonIconAnims,
.affineAnims = sMonIconAffineAnims,
.callback = callback,
.paletteTag = POKE_ICON_BASE_PAL_TAG + gMonIconPaletteIndices[species],
};
if (species > SPECIES_EGG)
iconTemplate.paletteTag = POKE_ICON_BASE_PAL_TAG;
spriteId = CreateMonIconSprite(&iconTemplate, x, y, subpriority);
UpdateMonIconFrame(&gSprites[spriteId]);
return spriteId;
}
u8 sub_80D2D78(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority, bool32 extra)
{
u8 spriteId;
struct MonIconSpriteTemplate iconTemplate =
{
.oam = &sMonIconOamData,
.image = NULL,
.anims = sMonIconAnims,
.affineAnims = sMonIconAffineAnims,
.callback = callback,
.paletteTag = POKE_ICON_BASE_PAL_TAG + gMonIconPaletteIndices[species],
};
iconTemplate.image = GetMonIconTiles(species, extra);
spriteId = CreateMonIconSprite(&iconTemplate, x, y, subpriority);
UpdateMonIconFrame(&gSprites[spriteId]);
return spriteId;
}
u16 mon_icon_convert_unown_species_id(u16 species, u32 personality)
{
u16 result;
if (species == SPECIES_UNOWN)
{
u16 letter = GetUnownLetterByPersonality(personality);
if (letter == 0)
letter = SPECIES_UNOWN;
else
letter += (SPECIES_UNOWN_B - 1);
result = letter;
}
else
{
if (species > SPECIES_EGG)
result = 260;
else
result = species;
}
return result;
}
u16 GetUnownLetterByPersonality(u32 personality)
{
if (!personality)
return 0;
return (((personality & 0x3000000) >> 18) | ((personality & 0x30000) >> 12) | ((personality & 0x300) >> 6) | (personality & 0x3)) % 0x1C;
}
u16 sub_80D2E84(u16 species)
{
u16 value;
if (MailSpeciesToSpecies(species, &value) == SPECIES_UNOWN)
{
if (value == 0)
value += SPECIES_UNOWN;
else
value += (SPECIES_UNOWN_B - 1);
return value;
}
else
{
if(species > (SPECIES_UNOWN_B - 1))
species = 260;
return mon_icon_convert_unown_species_id(species, 0);
}
}
const u8 *GetMonIconPtr(u16 species, u32 personality, bool32 extra)
{
return GetMonIconTiles(mon_icon_convert_unown_species_id(species, personality), extra);
}
void sub_80D2EF8(struct Sprite *sprite)
{
sub_80D328C(sprite);
}
void LoadMonIconPalettes(void)
{
u8 i;
for (i = 0; i < 6; i++)
LoadSpritePalette(&gMonIconPaletteTable[i]);
}
// unused
void SafeLoadMonIconPalette(u16 species)
{
u8 palIndex;
if (species > SPECIES_EGG)
species = 260;
palIndex = gMonIconPaletteIndices[species];
if (IndexOfSpritePaletteTag(gMonIconPaletteTable[palIndex].tag) == 0xFF)
LoadSpritePalette(&gMonIconPaletteTable[palIndex]);
}
void LoadMonIconPalette(u16 species)
{
u8 palIndex = gMonIconPaletteIndices[species];
if (IndexOfSpritePaletteTag(gMonIconPaletteTable[palIndex].tag) == 0xFF)
LoadSpritePalette(&gMonIconPaletteTable[palIndex]);
}
void FreeMonIconPalettes(void)
{
u8 i;
for (i = 0; i < 6; i++)
FreeSpritePaletteByTag(gMonIconPaletteTable[i].tag);
}
// unused
void SafeFreeMonIconPalette(u16 species)
{
u8 palIndex;
if (species > SPECIES_EGG)
species = 260;
palIndex = gMonIconPaletteIndices[species];
FreeSpritePaletteByTag(gMonIconPaletteTable[palIndex].tag);
}
void FreeMonIconPalette(u16 species)
{
u8 palIndex;
palIndex = gMonIconPaletteIndices[species];
FreeSpritePaletteByTag(gMonIconPaletteTable[palIndex].tag);
}
void sub_80D3014(struct Sprite *sprite)
{
UpdateMonIconFrame(sprite);
}
const u8* GetMonIconTiles(u16 species, bool32 extra)
{
const u8* iconSprite = gMonIconTable[species];
if(species == SPECIES_DEOXYS && extra == TRUE)
{
iconSprite = (const u8*)(0x400 + (u32)iconSprite); //WTF?
}
return iconSprite;
}
void sub_80D304C(u16 offset)
{
s32 i;
const struct SpritePalette* monIconPalettePtr;
if(offset <= 0xA0)
{
monIconPalettePtr = gMonIconPaletteTable;
for(i = 5; i >= 0 ; i--)
{
LoadPalette(monIconPalettePtr->data, offset, 0x20);
offset += 0x10;
monIconPalettePtr++;
}
}
}
u8 sub_80D3080(u16 species)
{
if (species > SPECIES_EGG)
species = 260;
return gMonIconPaletteIndices[species];
}
u8 sub_80D30A0(u16 species)
{
return gMonIconPaletteIndices[species];
}
const u16* GetValidMonIconPalettePtr(u16 species)
{
if (species > SPECIES_EGG)
species = 260;
return gMonIconPaletteTable[gMonIconPaletteIndices[species]].data;
}
// TODO: try to find a way to avoid using asm statement
u8 UpdateMonIconFrame(struct Sprite *sprite)
{
u8 result = 0;
if (sprite->animDelayCounter == 0)
{
s16 frame = sprite->anims[sprite->animNum][sprite->animCmdIndex].frame.imageValue;
switch (frame)
{
case -1:
break;
case -2:
sprite->animCmdIndex = 0;
break;
default:
RequestSpriteCopy(
// pointer arithmetic is needed to get the correct pointer to perform the sprite copy on.
// because sprite->images is a struct def, it has to be casted to (u8 *) before any
// arithmetic can be performed.
(u8 *)sprite->images + (sSpriteImageSizes[sprite->oam.shape][sprite->oam.size] * frame),
(u8 *)(OBJ_VRAM0 + sprite->oam.tileNum * TILE_SIZE_4BPP),
sSpriteImageSizes[sprite->oam.shape][sprite->oam.size]);
{
register u8 duration asm("r0") = sprite->anims[sprite->animNum][sprite->animCmdIndex].frame.duration;
sprite->animDelayCounter = duration;
}
sprite->animCmdIndex++;
result = sprite->animCmdIndex;
break;
}
}
else
{
sprite->animDelayCounter--;
}
return result;
}
static u8 CreateMonIconSprite(struct MonIconSpriteTemplate *iconTemplate, s16 x, s16 y, u8 subpriority)
{
u8 spriteId;
struct SpriteFrameImage image = { NULL, sSpriteImageSizes[iconTemplate->oam->shape][iconTemplate->oam->size] };
struct SpriteTemplate spriteTemplate =
{
.tileTag = 0xFFFF,
.paletteTag = iconTemplate->paletteTag,
.oam = iconTemplate->oam,
.anims = iconTemplate->anims,
.images = &image,
.affineAnims = iconTemplate->affineAnims,
.callback = iconTemplate->callback,
};
spriteId = CreateSprite(&spriteTemplate, x, y, subpriority);
gSprites[spriteId].animPaused = TRUE;
gSprites[spriteId].animBeginning = FALSE;
gSprites[spriteId].images = (const struct SpriteFrameImage *)iconTemplate->image;
return spriteId;
}
void sub_80D328C(struct Sprite *sprite)
{
struct SpriteFrameImage image = { NULL, sSpriteImageSizes[sprite->oam.shape][sprite->oam.size] };
sprite->images = &image;
DestroySprite(sprite);
}
void sub_80D32C8(struct Sprite *sprite, u8 animNum)
{
sprite->animNum = animNum;
sprite->animDelayCounter = 0;
sprite->animCmdIndex = 0;
}