From c68b734bfb149fcf31df8e377844698bde1905c4 Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Sat, 29 Jul 2023 01:06:51 +0200 Subject: [PATCH] Some more cleanup --- video.cc | 68 ++++++++++++-------------------------------------------- 1 file changed, 14 insertions(+), 54 deletions(-) diff --git a/video.cc b/video.cc index a36868e..067deb8 100644 --- a/video.cc +++ b/video.cc @@ -930,16 +930,17 @@ static void render_affine_object( // Renders objects on a scanline for a given priority. template static void render_scanline_objects( - u32 start, u32 end, stype *scanline, u32 priority + u32 priority, u32 start, u32 end, void *raw_ptr ) { // TODO move this to another place? // Skip alpha pass if you can do a regular color32 pass if (rdtype == STCKCOLOR && ((read_ioreg(REG_BLDCNT) >> 4) & 1) == 0) { // We cannot skip if there's some object being rendered TODO TODO - render_scanline_objects(start, end, scanline, priority); + render_scanline_objects(priority, start, end, raw_ptr); return; } + stype *scanline = (stype*)raw_ptr; s32 vcount = read_ioreg(REG_VCOUNT); bool obj1dmap = read_ioreg(REG_DISPCNT) & 0x40; u32 objn; @@ -1094,41 +1095,11 @@ static void render_scanline_objects( // There are actually used to render sprites to the scanline - -// WIP: Remove these once we merge things with partial alpha and copy mode. -void render_scanline_obj_normal_1D(u32 priority, u32 start, u32 end, void *raw_dst) { - render_scanline_objects(start, end, (u16*)raw_dst, priority); -} -void render_scanline_obj_normal_2D(u32 priority, u32 start, u32 end, void *raw_dst) { - render_scanline_objects(start, end, (u16*)raw_dst, priority); -} - -void render_scanline_obj_color16_1D(u32 priority, u32 start, u32 end, void *raw_dst) { - render_scanline_objects(start, end, (u16*)raw_dst, priority); -} -void render_scanline_obj_color16_2D(u32 priority, u32 start, u32 end, void *raw_dst) { - render_scanline_objects(start, end, (u16*)raw_dst, priority); -} - -void render_scanline_obj_color32_1D(u32 priority, u32 start, u32 end, void *raw_dst) { - render_scanline_objects(start, end, (u32*)raw_dst, priority); -} -void render_scanline_obj_color32_2D(u32 priority, u32 start, u32 end, void *raw_dst) { - render_scanline_objects(start, end, (u32*)raw_dst, priority); -} - -void render_scanline_obj_alpha_obj_1D(u32 priority, u32 start, u32 end, void *raw_dst) { - render_scanline_objects(start, end, (u32*)raw_dst, priority); -} -void render_scanline_obj_alpha_obj_2D(u32 priority, u32 start, u32 end, void *raw_dst) { - render_scanline_objects(start, end, (u32*)raw_dst, priority); -} - -static const tile_render_function obj_mode_renderers[4][2] = { - { render_scanline_obj_normal_2D, render_scanline_obj_normal_1D }, - { render_scanline_obj_color16_2D, render_scanline_obj_color16_1D }, - { render_scanline_obj_color32_2D, render_scanline_obj_color32_1D }, - { render_scanline_obj_alpha_obj_2D, render_scanline_obj_alpha_obj_1D }, +static const tile_render_function obj_mode_renderers[4] = { + render_scanline_objects, + render_scanline_objects, + render_scanline_objects, + render_scanline_objects, }; @@ -1384,17 +1355,6 @@ static void merge_brightness(u32 start, u32 end, u16 *srcdst) { } } -// Render an OBJ layer from start to end, depending on the type (1D or 2D) -// stored in dispcnt. - -#define render_obj_layer(type, dest, _start, _end) \ - current_layer &= ~0x04; \ - if(dispcnt & 0x40) \ - render_scanline_obj_##type##_1D(current_layer, _start, _end, dest); \ - else \ - render_scanline_obj_##type##_2D(current_layer, _start, _end, dest) \ - - // Render a target all the way with the background color as taken from the // palette. @@ -1475,7 +1435,7 @@ void render_layers(u32 start, u32 end, void *dst_ptr, u32 enabled_layers, else fill_line_background(start, end, dst_ptr); - obj_mode_renderers[obj_mode][(dispcnt >> 6) & 1](layer & 0x3, start, end, dst_ptr); + obj_mode_renderers[obj_mode](layer & 0x3, start, end, dst_ptr); break; } else if (!is_obj && ((1 << layer) & enabled_layers)) { @@ -1502,7 +1462,7 @@ void render_layers(u32 start, u32 end, void *dst_ptr, u32 enabled_layers, u32 layer = layer_order[lnum]; bool is_obj = layer & 0x4; if (is_obj && obj_enabled) - obj_mode_renderers[obj_mode][(dispcnt >> 6) & 1](layer & 0x3, start, end, dst_ptr); + obj_mode_renderers[obj_mode](layer & 0x3, start, end, dst_ptr); else if (!is_obj && ((1 << layer) & enabled_layers)) r[layer].trans[rend_mode](layer, start, end, dst_ptr); } @@ -1632,7 +1592,7 @@ static void render_scanline(u16 *scanline) current_layer = layer_order[layer_order_pos]; if(current_layer & 0x04) { - render_obj_layer(normal, scanline, 0, 240); + render_scanline_objects(current_layer & 3, 0, 240, scanline); } else { @@ -1690,7 +1650,7 @@ static void render_scanline_conditional_bitmap(u32 start, u32 end, u16 *scanline { if(enable_flags & 0x10) { - render_obj_layer(normal, scanline, start, end); + render_scanline_objects(current_layer & 3, start, end, scanline); } } else @@ -1757,9 +1717,9 @@ static void render_windowobj_pass(u16 *scanline, u32 start, u32 end) // Perform the actual object rendering in copy mode if (tiled) { // TODO: Make version 1D/2D? if (dispcnt & 0x40) - render_scanline_objects(start, end, scanline, 4); + render_scanline_objects(4, start, end, scanline); } else { - render_scanline_objects(start, end, scanline, 4); + render_scanline_objects(4, start, end, scanline); } } }