diff --git a/include/pokemon.h b/include/pokemon.h new file mode 100644 index 0000000..ea135b2 --- /dev/null +++ b/include/pokemon.h @@ -0,0 +1,8 @@ +#ifndef POKEMON_H +#define POKEMON_H + +#include + +class Pokemon; + +#endif \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp index d23e09f..f7f71ba 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -8,7 +8,7 @@ #include "gb_link.h" #include "gameboy_colour.h" #include "LinkGPIO.h" -#include "pokemon.cpp" +#include "pokemon.h" // This file is autogenerated from the file in the graphics folder #include "metr.h" @@ -141,8 +141,8 @@ int main(void) } tte_set_pos(0,30); - Pokemon test(2); - sprintf(str, "gen: %X", test.get()); + //Pokemon test(2); + //sprintf(str, "gen: %X", test.get()); tte_write(str); frame++; diff --git a/source/pokemon.cpp b/source/pokemon.cpp index dc4eafc..52ff990 100644 --- a/source/pokemon.cpp +++ b/source/pokemon.cpp @@ -1,56 +1,63 @@ #include +#include "pokemon.h" -#define pkmn_size(gen == 1 ? 44 : 48) -#define name_size 11 +#define pkmn_size ((gen == 1) ? 44 : 48) +#define name_size 11 -byte gen_one_pkmn_index[255]; -byte gen_two_pkmn_index[255]; +byte gen_one_pkmn_index[255] = {0}; +byte gen_two_pkmn_index[255] = {0}; - -class Pokemon{ +class Pokemon +{ public: - - void Pokemon(byte gen, int index, byte party_data[441]){ - num_of_pkmn = party_data[0x11]; - + Pokemon(byte gen, int index, byte party_data[441]) + { int party_offset = 20 + (index * 48); - int ot_offset = 20 + (6 * pkmn_size) + (index * name_size); - int name_offset = 20 + (6 * pkmn_size) + (6 * name_size) + (index * name_size); - - switch(gen){ - case 1: - + int ot_offset = 20 + (6 * pkmn_size) + (index * name_size); + int name_offset = 20 + (6 * pkmn_size) + (6 * name_size) + (index * name_size); + + switch (gen) + { + case 1: break; - case 2: - species_index = gen_one_pkmn_index[party_data[party_offset + 0x00]; - std::copy(party_data[party_offset + 0x02], party_data[party_offset + 0x06], moves[0]); - std::copy(party_data[party_offset + 0x06], party_data[party_offset + 0x08], trainer_id[0]; - exp[3]; //?? - std::copy(party_data[name_offset + 0x00], party_data[name_offset + 0x0A], nickname[0]); - std::copy(party_data[ot_offset + 0x00], party_data[name_offset + 0x0A], trainer_name[11]); - pokerus = party_data[party_offset + 0x1C]; - std::copy(party_data[party_offset + 0x1D], party_data[party_offset + 0x1F], caught_data[0]); - level; //?? + case 2: + species_index = gen_one_pkmn_index[party_data[party_offset + 0x00]]; + copy(party_data[party_offset + 0x02], party_data[party_offset + 0x06], moves[0]); + //std::copy(party_data[party_offset + 0x06], party_data[party_offset + 0x08], trainer_id[0]); + exp[3]; //?? + //std::copy(party_data[name_offset + 0x00], party_data[name_offset + 0x0A], nickname[0]); + //std::copy(party_data[ot_offset + 0x00], party_data[name_offset + 0x0A], trainer_name[11]); + pokerus = party_data[party_offset + 0x1C]; + //std::copy(party_data[party_offset + 0x1D], party_data[party_offset + 0x1F], caught_data[0]); + level; //?? break; - + } } - void convert_to_gen_three(){ - std::copy(gen_3_pkmn[0], gen_3_pkmn[3], blank_word[0]); // Personality Value - std::copy(gen_3_pkmn[4], gen_3_pkmn[5], blank_word[0]); // SID - std::copy(gen_3_pkmn[6], gen_3_pkmn[7], blank_word[0]); // TID + void convert_to_gen_three() + { + //std::copy(gen_3_pkmn[0], gen_3_pkmn[3], blank_word[0]); // Personality Value + //std::copy(gen_3_pkmn[4], gen_3_pkmn[5], blank_word[0]); // SID + //std::copy(gen_3_pkmn[6], gen_3_pkmn[7], blank_word[0]); // TID gen_3_pkmn[8] = 0xBB; gen_3_pkmn[9] = 0xFF; // Nickname // Language - // Egg Name(?) - // OT Name - // Markings + gen_3_pkmn[19] = 0b00000010; // Egg Name + gen_3_pkmn[20] = 0xBB; + gen_3_pkmn[21] = 0xFF; // OT Name + gen_3_pkmn[27] = 0b00000000; // Markings // Checksum // ??? // Data - { - + } + + void copy(int start, int stop, byte *array){ + for (int i = 0; i < (stop - start); i++){ + gen_3_pkmn[i + start] = array[i]; + } + } + private: byte gen; byte species_index; @@ -64,6 +71,4 @@ private: byte level; byte gen_3_pkmn[80]; byte blank_word[4] = {0}; - - } };