Advertisement
EliteAnax17

Untitled

May 4th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. I want to replace the last parameter of this multistruct with a macro.
  2.  
  3. const struct SaveSectionLocation gSaveSectionLocations[] =
  4. {
  5. {((u8 *) &gSaveBlock2), 0x890},
  6. {((u8 *) &gSaveBlock1) + 0xF80 * 0, 0xF80},
  7. {((u8 *) &gSaveBlock1) + 0xF80 * 1, 0xF80},
  8. {((u8 *) &gSaveBlock1) + 0xF80 * 2, 0xF80},
  9. {((u8 *) &gSaveBlock1) + 0xF80 * 3, 0xC40},
  10. {((u8 *) &gPokemonStorage) + 0xF80 * 0, 0xF80},
  11. {((u8 *) &gPokemonStorage) + 0xF80 * 1, 0xF80},
  12. {((u8 *) &gPokemonStorage) + 0xF80 * 2, 0xF80},
  13. {((u8 *) &gPokemonStorage) + 0xF80 * 3, 0xF80},
  14. {((u8 *) &gPokemonStorage) + 0xF80 * 4, 0xF80},
  15. {((u8 *) &gPokemonStorage) + 0xF80 * 5, 0xF80},
  16. {((u8 *) &gPokemonStorage) + 0xF80 * 6, 0xF80},
  17. {((u8 *) &gPokemonStorage) + 0xF80 * 7, 0xF80},
  18. {((u8 *) &gPokemonStorage) + 0xF80 * 8, 0x7D0}
  19. };
  20.  
  21. For the intended macro being GETCHUNKSIZE(chunk, n), The formula to figure out the constant is:
  22.  
  23. if (sizeof(chunk) - (0xF80 * (n - 1))) >= 0xF80
  24. return 0xF80
  25. else
  26. sizeof(chunk) // can optimize
  27.  
  28. Can I define this using a macro? the check itself isn't in the compiled ROM, these are hardcoded attributes. However, I would like to calculate them on the fly using a macro/define. Any way to do this?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement