diff --git a/pokemon_data.c b/pokemon_data.c index 4907cc48a05..d880953f0a8 100644 --- a/pokemon_data.c +++ b/pokemon_data.c @@ -129,6 +129,7 @@ PokemonData* pokemon_data_alloc(uint8_t gen) { case GEN_I: /* Allocate trade block and set its size for the trade view to use */ pdata->trade_block_sz = sizeof(TradeBlockGenI); + pdata->party_sz = sizeof(PokemonPartyGenI) * 6; pdata->trade_block = malloc(pdata->trade_block_sz); /* The party_members element needs to be 0xff for unused */ @@ -148,6 +149,7 @@ PokemonData* pokemon_data_alloc(uint8_t gen) { case GEN_II: /* Allocate trade block and set its size for the trade view to use */ pdata->trade_block_sz = sizeof(TradeBlockGenII); + pdata->party_sz = sizeof(PokemonPartyGenII) * 6; pdata->trade_block = malloc(pdata->trade_block_sz); /* The party_members element needs to be 0xff for unused */ diff --git a/pokemon_data.h b/pokemon_data.h index cd2586fa10a..3609388932b 100644 --- a/pokemon_data.h +++ b/pokemon_data.h @@ -53,6 +53,7 @@ struct pokemon_data { size_t trade_block_sz; /* Shortcut pointer to the actual party data in the trade block */ void* party; + size_t party_sz; /* Current EV/IV stat selection */ EvIv stat_sel; diff --git a/views/trade_patch_list.c b/views/trade_patch_list.c index c1020133cda..4bde3984106 100644 --- a/views/trade_patch_list.c +++ b/views/trade_patch_list.c @@ -49,7 +49,7 @@ uint8_t plist_index_get(struct patch_list* plist, int offset) { void plist_create(struct patch_list** pplist, PokemonData* pdata) { furi_assert(pdata); uint8_t* trade_party_flat = pdata->party; - int i; + size_t i; /* If plist is non-NULL that means its already been created. Tear it down * first. @@ -60,15 +60,13 @@ void plist_create(struct patch_list** pplist, PokemonData* pdata) { } *pplist = plist_alloc(); - /* NOTE: 264 magic number is the length of the party block, 44 * 6 */ /* The first half of the patch list covers offsets 0x00 - 0xfb, which * is expressed as 0x01 - 0xfc. An 0xFF byte is added to signify the * end of the first part. The second half of the patch list covers - * offsets 0xfc - 0x107. Which is expressed as 0x01 - 0xc. A 0xFF byte - * is added to signify the end of the second part/ + * offsets 0xfc - 0x107 (more in gen ii). Which is expressed as + * 0x01 - 0xc. A 0xFF byte is added to signify the end of the second part. */ - for(i = 0; i < 264; i++) { - FURI_LOG_D(TAG, "%02X", trade_party_flat[i]); + for(i = 0; i < pdata->party_sz; i++) { if(i == 0xFC) { FURI_LOG_D(TAG, "[plist] part 1 end"); plist_append(*pplist, 0xFF);