33 uint32_t initial_fade_frames = fade_frames_remaining;
35 if (fade_frames_remaining)
39 fade_frames_remaining -= 1;
46 int32_t opacity12 = (int32_t)(fade_frames_remaining << 0xc) / 0xa;
53 if (!fade_frames_remaining)
55 int32_t opaque_border_packed_height = (border_height + 1) << 0x10;
82 int32_t fading_border_packed_height = (border_height + 1) << 0x10;
95 int32_t transition_fraction_q12;
96 int32_t transition_boundary_frame;
98 if ((uint32_t)frame_index <= (uint32_t)transition_mid_frame)
102 if ((uint32_t)frame_index >= (uint32_t)transition_boundary_frame)
103 transition_fraction_q12 = 0;
111 if ((uint32_t)frame_index < (uint32_t)transition_boundary_frame)
113 ((uint32_t)(transition_mid_frame * 0xfffff + frame_index) << 0xc) / (uint32_t)(transition_boundary_frame - transition_mid_frame));
132 int32_t inner_half_height_q12 = (window_height - (window_height / 8) * 2) << 12 >> 1;
133 int64_t half_width_squared_product = (int64_t)(half_width_q12)*half_width_q12;
134 int64_t half_height_squared_product = (int64_t)(inner_half_height_q12)*inner_half_height_q12;
135 int32_t radius_squared_q12 = (int32_t)((uint64_t)half_height_squared_product >> 12) + (int32_t)((uint64_t)half_width_squared_product >> 12);
136 int64_t radius_product = (int64_t)
Math_SqrtFP12(radius_squared_q12) * transition_fraction_q12;
137 int32_t transition_radius = (int32_t)(uint32_t)((uint64_t)radius_product >> 12) >> 12;
140 if (left_border_width > 0)
142 uint32_t side_border_packed_width = (uint32_t)((uint16_t)left_border_width + 1);
151 if (top_border_height > 0)
153 int32_t top_border_packed_height = (top_border_height + 1) << 0x10;
161 uint32_t packed_xy = top_border_height << 0x10 | (left_border_width & 0xffff);
162 int32_t packed_wh = transition_radius << 0x10 | (uint32_t)(uint16_t)transition_radius;
185 int32_t left = (int16_t)packed_origin_xy;
186 int32_t top = (int16_t)((uint32_t)packed_origin_xy >> 16);
187 int32_t right = left + (int16_t)packed_size_wh;
188 int32_t bottom = top + (int16_t)((uint32_t)packed_size_wh >> 16);
204 const uint32_t colors[4] = {top_left_rgb, top_right_rgb, bottom_left_rgb, bottom_right_rgb};
212 for (
unsigned i = 0; i < 4; ++i)
214 vertices[i].
screen.
x = (float)((i & 1) ? right : left);
215 vertices[i].
screen.
y = (float)((i & 2) ? bottom : top);
218 vertices[i].
diffuse_color = ((uint32_t)alpha << 24) | ((colors[i] & 0xff) << 16) | (colors[i] & 0xff00) | ((colors[i] >> 16) & 0xff);
221 g_d3dDevice7->lpVtbl->DrawPrimitive(
g_d3dDevice7, D3DPT_TRIANGLESTRIP, (D3DFVF_XYZRHW | D3DFVF_DIFFUSE), vertices, 4, 0);
231 int32_t left = (int32_t)(int16_t)packed_origin_xy;
232 int32_t top = (int32_t)(int16_t)(packed_origin_xy >> 0x10);
237 uint8_t alpha = (uint8_t)((opacity12 * 0xff) >> 12);
246 if (!depth_state_unavailable)
250 disable_depth_device->lpVtbl->SetRenderState(disable_depth_device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
256 long double left_precise = (
long double)left;
258 float top_left_x = (float)left_precise;
259 long double top_precise = (
long double)top;
262 uint32_t alpha_color = (uint32_t)alpha << 24;
263 float top_left_y = (float)top_precise;
264 long double right_precise = (
long double)((int32_t)(int16_t)packed_size_wh + left);
268 float top_right_x = (float)right_precise;
269 float top_right_y = (float)top_precise;
273 float bottom_right_x = (float)right_precise;
274 float bottom_left_x = (float)left_precise;
275 long double bottom_precise = (
long double)((int32_t)(int16_t)(packed_size_wh >> 0x10) + top);
276 float bottom_left_y = (float)bottom_precise;
277 float bottom_right_y = (float)bottom_precise;
289 {top_left_x, top_left_y, 9.99999997e-7f, 9.99999997e-7f, (uint32_t)alpha_color},
290 {top_right_x, top_right_y, 9.99999997e-7f, 9.99999997e-7f, (uint32_t)alpha_color},
291 {bottom_left_x, bottom_left_y, 9.99999997e-7f, 9.99999997e-7f, (uint32_t)alpha_color},
292 {bottom_right_x, bottom_right_y, 9.99999997e-7f, 9.99999997e-7f, (uint32_t)alpha_color}};
294 draw_device->lpVtbl->DrawPrimitive(draw_device, D3DPT_TRIANGLESTRIP, (D3DFVF_XYZRHW | D3DFVF_DIFFUSE), vertices, 4, 0);
301 restore_depth_device->lpVtbl->SetRenderState(restore_depth_device, D3DRENDERSTATE_ZENABLE, D3DZB_TRUE);
342 uint8_t hold_timer = gradient_state->
holdTimer;
346 gradient_state->
holdTimer = hold_timer - 1;
348 int32_t held_intensity = (uint8_t)(gradient_state->
currentValue);
350 return held_intensity;
353 char signed_step = gradient_state->
signedStep;
354 int32_t current_intensity = (uint8_t)(gradient_state->
currentValue);
355 int32_t high_intensity = (uint8_t)(gradient_state->
highValue);
356 int32_t next_intensity = current_intensity + (int32_t)signed_step;
358 if (next_intensity >= high_intensity)
360 uint8_t clamped_high_intensity = (uint8_t)high_intensity;
366 return (uint32_t)clamped_high_intensity;
369 int32_t low_intensity = (uint8_t)(gradient_state->
lowValue);
371 if (next_intensity <= low_intensity)
373 next_intensity = low_intensity;
380 return next_intensity & 0xff;
387 const uint32_t base_colors[2] = {0xfc8639, 0xd6ff8e};
390 for (
unsigned row = 0; row < 2; ++row)
392 colors[row] = base_colors[row];
398 for (
unsigned shift = 0; shift < 24; shift += 8)
400 int32_t base_channel = (base_colors[row] >> shift) & 255;
401 int32_t channel_adjustment = ((text_flags >> shift) & 255) - 128;
402 int32_t adjusted_channel = base_channel + ((channel_adjustment * (channel_adjustment <= 0 ? base_channel : 255 - base_channel)) >> 7);
404 if (adjusted_channel < 0)
405 adjusted_channel = 0;
407 if (adjusted_channel > 255)
408 adjusted_channel = 255;
410 colors[row] |= (uint32_t)adjusted_channel << shift;
415 *out_top_color = colors[0];
416 *out_bottom_color = colors[1];
456 int32_t red_adjust_byte = (uint8_t)(material->
color_adjust.
r);
457 int32_t green_adjust_byte = (uint8_t)(material->
color_adjust.
g);
458 int32_t blue_adjust_byte = (uint8_t)(material->
color_adjust.
b);
459 const uint32_t *input_color_cursor = input_colors;
460 int32_t blue_adjust = blue_adjust_byte - 0x80;
462 for (
unsigned color_index = 0; color_index < 4; ++color_index)
464 uint32_t source_rgb = *input_color_cursor & 0xffffff;
466 input_color_cursor = &input_color_cursor[1];
468 int32_t source_red = (uint8_t)source_rgb;
469 int32_t adjusted_red = source_red + red_adjust_byte - 0x80;
471 if (adjusted_red < 0)
473 else if (adjusted_red > 0xff)
476 int32_t source_green = (uint8_t)((uint8_t)((uint32_t)source_rgb >> 8));
477 int32_t adjusted_green = source_green + green_adjust_byte - 0x80;
479 if (adjusted_green < 0)
481 else if (adjusted_green > 0xff)
482 adjusted_green = 0xff;
484 int32_t source_blue = (uint8_t)((uint8_t)((uint32_t)source_rgb >> 16));
485 int32_t adjusted_blue = source_blue + blue_adjust;
487 if (adjusted_blue < 0)
489 else if (adjusted_blue > 0xff)
490 adjusted_blue = 0xff;
492 *output_colors = ((uint32_t)adjusted_blue << 16) | ((uint32_t)adjusted_green << 8) | (uint32_t)adjusted_red;
493 output_colors = &output_colors[1];
struct Math_ColorRGB8 color_adjust