فهرست منبع

patch_list: Add party_sz to main pokemon data struct

Remove noisy debug, don't need to print out entire patch list

Signed-off-by: Kris Bahnsen <Kris@KBEmbedded.com>
Kris Bahnsen 1 سال پیش
والد
کامیت
a9828860ba
3فایلهای تغییر یافته به همراه7 افزوده شده و 6 حذف شده
  1. 2 0
      pokemon_data.c
  2. 1 0
      pokemon_data.h
  3. 4 6
      views/trade_patch_list.c

+ 2 - 0
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 */

+ 1 - 0
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;

+ 4 - 6
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);