40 linked_sprite_base = sprite_list;
41 sprite_list_local = sprite_list;
45 sprite_list_local = NULL;
46 linked_sprite_base = NULL;
49 if (!sprite_list_local)
69 if ((uintptr_t)sprite_cursor >= (uintptr_t)ancestor_sprite)
72 uint8_t ancestor_link_index = ancestor_sprite->link_index;
74 if (ancestor_link_index == 0xff)
77 ancestor_sprite = &sprite_list_local[ancestor_link_index];
82 uint8_t invalidated_state_flags = sprite_cursor->
state_flags;
96 *node_payload = sprite_cursor;
102 sprite_cursor = &sprite_cursor[1];
105 int32_t bounds_width = 0, bounds_height = 0;
106 uint32_t composed_render_flags = 0;
114 uint16_t initial_control_flags;
137 .
r = (uint8_t)color_target_word,
138 .g = (uint8_t)((uint32_t)color_target_word >> 8),
139 .b = (uint8_t)((uint32_t)color_target_word >> 16)};
149 if ((uint32_t)color_current_frame < (uint32_t)color_end_frame)
159 (char)(((target_red - (uint32_t)start_color_channel) * color_ease_factor) >>
MATH_Q12_SHIFT) + start_color_channel;
165 (char)(((target_green - (uint32_t)start_color_channel) * color_ease_factor) >>
MATH_Q12_SHIFT) + start_color_channel;
169 uint8_t interpolated_blue =
170 (char)(((target_blue - (uint32_t)start_color_channel) * color_ease_factor) >>
MATH_Q12_SHIFT) + start_color_channel;
184 if (rotation_end_frame)
188 if ((uint32_t)rotation_current_frame < (uint32_t)rotation_end_frame)
217 if ((uint32_t)scale_current_frame < (uint32_t)scale_end_frame)
229 int64_t scale_y_product = (int64_t)(target_scale_y - sprite->
scale_start.
y) * scale_ease_factor;
241 int32_t move_y_or_layer_index = (int32_t)sprite->
move_target.
y;
244 draw_x = target_move_x;
245 draw_y = move_y_or_layer_index;
247 if (move_end_frame_or_start_y)
249 if ((uint32_t)
g_frameCounter < (uint32_t)move_end_frame_or_start_y)
255 int32_t start_move_x = (int32_t)sprite->
move_start.
x;
257 move_end_frame_or_start_y = (int32_t)sprite->
move_start.
y;
258 draw_x = (((target_move_x - start_move_x) * move_ease_factor) >>
MATH_Q12_SHIFT) + start_move_x;
259 move_y_or_layer_index = (((move_y_or_layer_index - move_end_frame_or_start_y) * move_ease_factor) >>
MATH_Q12_SHIFT) + move_end_frame_or_start_y;
260 draw_y = move_y_or_layer_index;
268 uint8_t parent_link_byte = sprite->
link_index;
269 int16_t layer_sort_key = (int16_t)((uint16_t)sprite->
layer_index << 6);
273 if (parent_link_byte != 0xff)
275 uint32_t parent_link_index = (uint32_t)parent_link_byte;
276 struct PKG_SpriteEntry *parent_sprite = &linked_sprite_base[parent_link_index];
299 sprite->
sort_key = (uint16_t)(parent_sprite->
sort_key + layer_sort_key + 1);
307 .
r = (uint8_t)parent_color_word,
308 .g = (uint8_t)((uint32_t)parent_color_word >> 8),
309 .b = (uint8_t)((uint32_t)parent_color_word >> 16)};
314 int32_t parent_scale_x;
319 int32_t parent_scaled_y;
325 draw_y = parent_scaled_y;
327 int64_t inherited_scale_x_product = (int64_t)parent_scale_x * sprite->
current_scale.
x;
336 parent_scaled_y = draw_y;
340 int32_t anchor_code = (uint8_t)(sprite->
anchor_code);
342 draw_x += (int32_t)(int16_t)parent_sprite->
bounds.
x;
344 int32_t parent_height = (int32_t)(int16_t)parent_sprite->
bounds.
h;
345 int32_t parent_translated_y = parent_scaled_y + (int32_t)(int16_t)parent_sprite->
bounds.
y;
346 int32_t parent_width = (int32_t)(int16_t)parent_sprite->
bounds.
w;
348 draw_y = parent_translated_y;
349 bounds_width = parent_width;
350 bounds_height = parent_height;
352 if (anchor_code - 1 <= 7)
357 draw_x = draw_x + parent_width - 1;
364 draw_y = parent_translated_y + parent_height - 1;
371 draw_x = draw_x + parent_width - 1;
372 draw_y = parent_translated_y + parent_height - 1;
379 draw_y = parent_translated_y + (parent_height >> 1);
386 draw_x += parent_width >> 1;
393 draw_x = draw_x + parent_width - 1;
394 draw_y = parent_translated_y + (parent_height >> 1);
401 draw_x += parent_width >> 1;
402 draw_y = parent_translated_y + parent_height - 1;
409 draw_x += parent_width >> 1;
410 draw_y = parent_translated_y + (parent_height >> 1);
427 int32_t parent_control_flags = (uint16_t)parent_sprite->
control_flags;
428 int32_t parent_bounds_x = (int32_t)(int16_t)parent_sprite->
bounds.
x;
429 int32_t parent_pivot_y = (int32_t)(int16_t)parent_sprite->
bounds.
y;
430 int32_t parent_pivot_x = parent_bounds_x;
432 int32_t saved_parent_pivot_y = parent_pivot_y;
435 parent_pivot_x = parent_bounds_x + ((int32_t)(int16_t)parent_sprite->
bounds.
w >> 1);
437 parent_pivot_x = parent_bounds_x + (int32_t)(int16_t)parent_sprite->
bounds.
w - 1;
443 parent_pivot_y += (int32_t)(int16_t)parent_sprite->
bounds.
h >> 1;
444 saved_parent_pivot_y = parent_pivot_y;
448 parent_pivot_y = parent_pivot_y + (int32_t)(int16_t)parent_sprite->
bounds.
h - 1;
449 saved_parent_pivot_y = parent_pivot_y;
456 int32_t negative_parent_sin = -((
Math_SinQ14(angle) >> 2));
457 int32_t relative_pivot_x = draw_x - parent_pivot_x;
458 int32_t relative_pivot_y = draw_y - parent_pivot_y;
459 int32_t parent_cos =
Math_SinQ14(0x400 - angle) >> 2;
461 draw_x = ((relative_pivot_x * parent_cos - relative_pivot_y * negative_parent_sin) >>
MATH_Q12_SHIFT) + parent_pivot_x;
462 draw_y = ((relative_pivot_y * parent_cos + relative_pivot_x * negative_parent_sin) >>
MATH_Q12_SHIFT) + saved_parent_pivot_y;
468 int16_t computed_screen_x = (uint16_t)draw_x;
470 pivot_x = computed_screen_x;
471 sprite->
screen.
x = computed_screen_x;
473 sprite->
screen.
y = (uint16_t)draw_y;
477 int32_t cached_screen_x = (int32_t)sprite->
screen.
x;
479 draw_x = cached_screen_x;
480 pivot_x = (uint16_t)cached_screen_x;
482 int32_t cached_screen_y = (int32_t)sprite->
screen.
y;
484 draw_y = cached_screen_y;
485 pivot_y = cached_screen_y;
497 int32_t material_red;
503 int32_t modulated_red = material_red + sprite_red - 0x80;
505 if (modulated_red < 0)
507 else if (modulated_red > 0xff)
508 modulated_red = 0xff;
510 int32_t material_green;
511 int32_t sprite_green;
515 composed_render_flags = (uint8_t)modulated_red;
517 int32_t modulated_green = material_green + sprite_green - 0x80;
519 if (modulated_green < 0)
521 else if (modulated_green > 0xff)
522 modulated_green = 0xff;
524 composed_render_flags |= (uint32_t)(uint8_t)modulated_green << 8;
526 int32_t material_blue = (uint8_t)(sprite_ctx1->
color_mod.
b);
528 int32_t modulated_blue = material_blue + sprite_blue - 0x80;
530 if (modulated_blue < 0)
532 else if (modulated_blue > 0xff)
533 modulated_blue = 0xff;
535 composed_render_flags |= (uint32_t)(uint8_t)modulated_blue << 16;
545 composed_render_flags = current_color_word;
553 uint8_t sprite_type = sprite->
type;
567 int32_t glyph_height;
573 int32_t unscaled_glyph_width;
574 uint32_t unscaled_glyph_height;
576 if (glyph_descriptor)
578 int32_t glyph_width_minus_one;
579 int32_t glyph_height_minus_one;
583 unscaled_glyph_width = glyph_width_minus_one + 1;
584 unscaled_glyph_height = glyph_height_minus_one + 1;
592 int32_t glyph_control_flags = (uint16_t)sprite->
control_flags;
598 bounds_height = glyph_height;
608 draw_y -= glyph_height >> 1;
610 draw_y += 1 - glyph_height;
614 draw_x = (int32_t)sprite->
bounds.
x;
615 draw_y = (int32_t)sprite->
bounds.
y;
616 glyph_height = (int32_t)sprite->
bounds.
h;
617 bounds_height = glyph_height;
622 uint32_t glyph_render_flags = composed_render_flags;
644 saved_font_ref = font_ref;
649 char (*text_buffer)[0x14];
655 char (*resolved_string)[0x14];
657 if (string_resource_id >= 0)
662 text_buffer = resolved_string;
666 text_buffer = &buffer;
670 int32_t scale_text_glyphs;
673 scale_text_glyphs = 0;
676 scale_text_glyphs = 1;
688 text_width = (int32_t)sprite->
bounds.
w;
689 bounds_width = text_width;
694 int32_t text_height = 0;
695 int32_t measure_character = (int32_t)*(int8_t *)text_buffer;
698 bounds_width = text_width;
701 char *measure_cursor = &((
char *)text_buffer)[1];
703 if (measure_character)
708 glyph_descriptor_table[measure_character - 32];
712 int32_t measure_glyph_width;
714 if (!sprite_ctx2 || !measure_glyph_descriptor)
715 measure_glyph_width = 1;
720 measure_glyph_width = measure_width_minus_one + 1;
726 int32_t measure_glyph_height;
728 if (!sprite_ctx2 || !measure_glyph_descriptor)
729 measure_glyph_height = 1;
734 measure_glyph_height = measure_height_minus_one + 1;
737 text_height = bounds_height;
739 if (measure_glyph_height > text_height)
741 if (!sprite_ctx2 || !measure_glyph_descriptor)
747 text_height = max_glyph_height_minus_one + 1;
750 bounds_height = text_height;
753 measure_character = (int32_t)*(int8_t *)measure_cursor;
754 measure_cursor = &measure_cursor[1];
755 }
while (measure_character);
757 bounds_width = text_width;
760 if (scale_text_glyphs)
764 bounds_width = text_width;
765 bounds_height = text_height;
768 int32_t text_control_flags = (uint16_t)sprite->
control_flags;
773 draw_x -= text_width >> 1;
774 text_height = bounds_height;
778 draw_x += 1 - text_width;
779 text_height = bounds_height;
785 draw_y -= text_height >> 1;
787 draw_y += 1 - text_height;
791 draw_x = (int32_t)sprite->
bounds.
x;
792 draw_y = (int32_t)sprite->
bounds.
y;
793 bounds_height = (int32_t)sprite->
bounds.
h;
800 char (*special_text_scan)[0x14] = text_buffer;
803 while (special_text_scan_remaining)
805 bool special_text_char_nonzero = 0 != *(uint8_t *)special_text_scan;
807 special_text_scan = (char (*)[20])(&((
char *)special_text_scan)[1]);
808 special_text_scan_remaining -= 1;
810 if (!special_text_char_nonzero)
814 text_width = bounds_width;
815 draw_x = (0x20 - (~special_text_scan_remaining - 1)) * 0xa;
820 char (*render_text_buffer)[0x14] = text_buffer;
824 char (*saved_render_text_buffer)[0x14] = render_text_buffer;
826 if (content_value == 0x453 && draw_y > 0x1d6)
829 int32_t rotation_pivot_xy = pivot_y <<
UI_PACKED_Y_SHIFT | (uint32_t)(uint16_t)pivot_x;
831 int16_t special_text_x_offset = 0;
833 if (content_value == 0xa)
837 if ((content_value == 0x18 || content_value == 0x17) && rotation_pivot_xy == 0x1b60140)
840 saved_render_text_buffer = render_text_buffer;
841 special_text_x_offset = 0x96;
845 if (scale_text_glyphs)
847 int32_t scaled_character = (int32_t)*(int8_t *)render_text_buffer;
848 int32_t unscaled_text_advance = 0;
849 char *scaled_text_cursor = &((
char *)render_text_buffer)[1];
851 while (scaled_character)
854 glyph_descriptor_table[scaled_character - 32];
858 int32_t scaled_glyph_base_height;
860 if (!sprite_ctx2 || !scaled_glyph_descriptor)
861 scaled_glyph_base_height = 1;
866 scaled_glyph_base_height = scaled_glyph_height_minus_one + 1;
869 int32_t scaled_glyph_base_width;
871 if (!sprite_ctx2 || !scaled_glyph_descriptor)
872 scaled_glyph_base_width = 1;
877 scaled_glyph_base_width = scaled_glyph_width_minus_one + 1;
886 sprite_ctx2, composed_render_flags, rotation_angle, rotation_pivot_xy);
893 int32_t scaled_advance_width;
895 if (!sprite_ctx2 || !scaled_advance_descriptor)
896 scaled_advance_width = 1;
901 scaled_advance_width = scaled_advance_width_minus_one + 1;
904 scaled_character = (int32_t)*(int8_t *)scaled_text_cursor;
905 unscaled_text_advance +=
907 scaled_text_cursor = &scaled_text_cursor[1];
912 int32_t packed_xy = (uint32_t)(uint16_t)(draw_x - special_text_x_offset) | draw_y <<
UI_PACKED_Y_SHIFT;
913 int32_t unscaled_character = (int32_t)*(int8_t *)saved_render_text_buffer;
914 char *unscaled_text_cursor = &((
char *)saved_render_text_buffer)[1];
916 while (unscaled_character)
919 glyph_descriptor_table[unscaled_character - 32];
921 uint32_t render_flags = composed_render_flags;
925 rotation_angle, rotation_pivot_xy);
932 int32_t unscaled_advance_width;
934 if (!sprite_ctx2 || !texture_descriptor)
935 unscaled_advance_width = 1;
940 unscaled_advance_width = unscaled_advance_width_minus_one + 1;
945 unscaled_character = (int32_t)*(int8_t *)unscaled_text_cursor;
946 unscaled_text_cursor = &unscaled_text_cursor[1];
959 sprite->
bounds.
x = (uint16_t)draw_x;
960 sprite->
bounds.
y = (uint16_t)draw_y;
961 sprite->
bounds.
w = (uint16_t)bounds_width;
962 sprite->
bounds.
h = (uint16_t)bounds_height;