@@ -272,6 +272,74 @@ SERUM_EDITOR_API bool SerumEditor_RenderFrame(
272272 return true ;
273273}
274274
275+ SERUM_EDITOR_API bool SerumEditor_RenderFrameWithRotations (
276+ const SerumEditorDataView* data, const SerumEditorFrameView* frame,
277+ const SerumEditorSpriteMatch* matches, uint8_t match_count, bool use_extra,
278+ const uint16_t * rotations, const uint32_t * shifts, uint16_t * out_frame,
279+ uint16_t * rotations_in_frame) {
280+ if (!data || !frame || !out_frame || !frame->original ) {
281+ return false ;
282+ }
283+ const uint32_t width = use_extra ? data->width_extra : data->width ;
284+ const uint32_t height = use_extra ? data->height_extra : data->height ;
285+ if (width == 0 || height == 0 ) {
286+ return false ;
287+ }
288+
289+ SerumV2RenderFrameInput input{};
290+ input.width = width;
291+ input.height = height;
292+ input.base_width = data->width ;
293+ input.base_height = data->height ;
294+ input.nocolors = data->nocolors ;
295+ input.base_frame = frame->original ;
296+ input.colorized = use_extra ? frame->colorized_extra : frame->colorized ;
297+ input.dyna_mask = use_extra ? frame->dynamask_extra : frame->dynamask ;
298+ input.dyna_colors = use_extra ? frame->dyna4cols_extra : frame->dyna4cols ;
299+ if (frame->background_id != 0xffff ) {
300+ input.background_mask =
301+ use_extra ? frame->background_mask_extra : frame->background_mask ;
302+ input.background_frame =
303+ use_extra ? frame->background_frame_extra : frame->background_frame ;
304+ }
305+
306+ SerumV2RenderRotationInput rotation{};
307+ rotation.rotations = rotations;
308+ rotation.shifts = shifts;
309+ SerumV2_RenderFrame (&input, rotations ? &rotation : nullptr , out_frame,
310+ rotations_in_frame);
311+
312+ if (matches && data->sprites ) {
313+ for (uint8_t i = 0 ; i < match_count; ++i) {
314+ const uint8_t sprite_id = matches[i].sprite_index ;
315+ if (sprite_id == 255 || sprite_id >= data->nsprites ) {
316+ continue ;
317+ }
318+ const SerumEditorSpriteView& sprite = data->sprites [sprite_id];
319+ SerumV2RenderSpriteInput sprite_input;
320+ sprite_input.sprite_original = sprite.original ;
321+ sprite_input.sprite_colored = sprite.colored ;
322+ sprite_input.sprite_mask_extra = sprite.mask_extra ;
323+ sprite_input.sprite_colored_extra = sprite.colored_extra ;
324+ sprite_input.dynasprite_mask = sprite.dynasprite_mask ;
325+ sprite_input.dynasprite_mask_extra = sprite.dynasprite_mask_extra ;
326+ sprite_input.dynasprite_cols = sprite.dynasprite_cols ;
327+ sprite_input.dynasprite_cols_extra = sprite.dynasprite_cols_extra ;
328+ SerumV2SpritePlacement placement;
329+ placement.frx = matches[i].frx ;
330+ placement.fry = matches[i].fry ;
331+ placement.spx = matches[i].spx ;
332+ placement.spy = matches[i].spy ;
333+ placement.wid = matches[i].wid ;
334+ placement.hei = matches[i].hei ;
335+ SerumV2_RenderSprite (&input, &sprite_input, &placement,
336+ rotations ? &rotation : nullptr , out_frame,
337+ rotations_in_frame);
338+ }
339+ }
340+ return true ;
341+ }
342+
275343SERUM_EDITOR_API void SerumEditor_InitRotationState (
276344 const uint16_t * rotations, SerumEditorRotationState* state,
277345 uint32_t now_ms) {
@@ -298,3 +366,20 @@ SERUM_EDITOR_API uint32_t SerumEditor_ApplyRotations(
298366 state->next_time_ms , state->shift , state->active , now_ms, nullptr ,
299367 nullptr , true , nullptr );
300368}
369+
370+ SERUM_EDITOR_API uint32_t SerumEditor_ApplyRotationsMasked (
371+ const uint16_t * rotations, const uint16_t * input_frame,
372+ uint16_t * output_frame, uint16_t * rotations_in_frame, uint32_t width,
373+ uint32_t height, SerumEditorRotationState* state, uint32_t now_ms) {
374+ if (!rotations || !input_frame || !output_frame || width == 0 ||
375+ height == 0 || !state || !rotations_in_frame) {
376+ return 0 ;
377+ }
378+ std::memcpy (output_frame, input_frame,
379+ static_cast <std::size_t >(width) * height * sizeof (uint16_t ));
380+
381+ return SerumV2_ApplyRotations (
382+ rotations, output_frame, rotations_in_frame,
383+ static_cast <uint32_t >(width) * height, state->next_time_ms , state->shift ,
384+ state->active , now_ms, nullptr , nullptr , true , nullptr );
385+ }
0 commit comments