Why does format_read_entries only work for dynamic arrays? #2516
Unanswered
camprevail
asked this question in
Get Help
Replies: 2 comments 5 replies
-
|
static arrays are optimized for speed so that it is not possible to make them work with format_read_entries. The optimization only looks at the first value so that the rest cannot be transformed. You can always make the static array dynamic or you can also create a pattern for the array element and assign a format to it . s16 coord_chunk[short_count] [[format_read("fmt_read_entries_div20")]];do struct Element {
s16 data;
} [[format_read("fmt_read_div20")]];
fn fmt_read_div20(auto val) {
//return float(int) / 20.0;
return float(val) / 20.0f;
};
Element coord_chunk[short_count]; |
Beta Was this translation helpful? Give feedback.
4 replies
-
|
Had to move the format_read up to the value cause it was trying to cast the struct to a float, but we're cooking now. struct Element {
s16 data [[format_read("fmt_read_flt_div20")]];
} [[inline]];
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
-
Based on the docs, it looked like format_read_entries should do exactly what it says and apply the format func to each array member. It kept crashing imhex though so I updated to nightly and the exception message said it only works on dynamic arrays. Is this something that could be made to work on fixed size arrays in the future, or is there a reason that it can't?
Is there another way I can apply a format func to each value in an array?
format_readseems to work just fine but that's not really what I need.Beta Was this translation helpful? Give feedback.
All reactions