Skip to content

Commit

Permalink
patch_list: Add party_sz to main pokemon data struct
Browse files Browse the repository at this point in the history
Remove noisy debug, don't need to print out entire patch list

Signed-off-by: Kris Bahnsen <Kris@KBEmbedded.com>
  • Loading branch information
kbembedded committed May 22, 2024
1 parent e0581ec commit a982886
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 2 additions & 0 deletions pokemon_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions pokemon_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 4 additions & 6 deletions views/trade_patch_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand Down

0 comments on commit a982886

Please sign in to comment.