Skip to content

Commit

Permalink
butano: h-blank effects optimized (it fixes world_map example flicker…
Browse files Browse the repository at this point in the history
…ing)
  • Loading branch information
GValiente committed Dec 3, 2020
1 parent e9c6a27 commit 9be5818
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 12 deletions.
10 changes: 10 additions & 0 deletions butano/hw/include/bn_hw_hblank_effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ namespace bn::hw::hblank_effects
public:
const uint16_t* src;
volatile uint16_t* dest;

void update(unsigned vcount)
{
*dest = src[vcount];
}
};

class uint32_entry
Expand All @@ -25,6 +30,11 @@ namespace bn::hw::hblank_effects
public:
const unsigned* src;
volatile unsigned* dest;

void update(unsigned vcount)
{
*dest = src[vcount];
}
};

class entries
Expand Down
104 changes: 96 additions & 8 deletions butano/hw/src/bn_hw_hblank_effects.bn_iwram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,109 @@ void _intr()

entries* entries_ptr = data.entries_ptr;
uint16_entry* uint16_entries = entries_ptr->uint16_entries;
int uint16_entries_count = entries_ptr->uint16_entries_count;

for(int index = 0; index < uint16_entries_count; ++index)
switch(entries_ptr->uint16_entries_count)
{
uint16_entry& entry = uint16_entries[index];
*entry.dest = entry.src[vcount];

case 0:
break;

case 1:
uint16_entries[0].update(vcount);
break;

case 2:
uint16_entries[0].update(vcount);
uint16_entries[1].update(vcount);
break;

case 3:
uint16_entries[0].update(vcount);
uint16_entries[1].update(vcount);
uint16_entries[2].update(vcount);
break;

case 4:
uint16_entries[0].update(vcount);
uint16_entries[1].update(vcount);
uint16_entries[2].update(vcount);
uint16_entries[3].update(vcount);
break;

case 5:
uint16_entries[0].update(vcount);
uint16_entries[1].update(vcount);
uint16_entries[2].update(vcount);
uint16_entries[3].update(vcount);
uint16_entries[4].update(vcount);
break;

case 6:
uint16_entries[0].update(vcount);
uint16_entries[1].update(vcount);
uint16_entries[2].update(vcount);
uint16_entries[3].update(vcount);
uint16_entries[4].update(vcount);
uint16_entries[5].update(vcount);
break;

case 7:
uint16_entries[0].update(vcount);
uint16_entries[1].update(vcount);
uint16_entries[2].update(vcount);
uint16_entries[3].update(vcount);
uint16_entries[4].update(vcount);
uint16_entries[5].update(vcount);
uint16_entries[6].update(vcount);
break;

case 8:
uint16_entries[0].update(vcount);
uint16_entries[1].update(vcount);
uint16_entries[2].update(vcount);
uint16_entries[3].update(vcount);
uint16_entries[4].update(vcount);
uint16_entries[5].update(vcount);
uint16_entries[6].update(vcount);
uint16_entries[7].update(vcount);
break;

default:
break;
}

uint32_entry* uint32_entries = entries_ptr->uint32_entries;
int uint32_entries_count = entries_ptr->uint32_entries_count;

for(int index = 0; index < uint32_entries_count; ++index)
switch(entries_ptr->uint32_entries_count)
{
uint32_entry& entry = uint32_entries[index];
*entry.dest = entry.src[vcount];

case 0:
break;

case 1:
uint32_entries[0].update(vcount);
break;

case 2:
uint32_entries[0].update(vcount);
uint32_entries[1].update(vcount);
break;

case 3:
uint32_entries[0].update(vcount);
uint32_entries[1].update(vcount);
uint32_entries[2].update(vcount);
break;

case 4:
uint32_entries[0].update(vcount);
uint32_entries[1].update(vcount);
uint32_entries[2].update(vcount);
uint32_entries[3].update(vcount);
break;

default:
break;
}
}

Expand Down
5 changes: 3 additions & 2 deletions butano/include/bn_documentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -1041,9 +1041,10 @@
* @tableofcontents
*
*
* @section changelog_4_0_1 4.0.1 (next release)
* @section changelog_4_1_0 4.1.0 (next release)
*
* SRAM code moved from EWRAM to ROM to avoid a No$gba crash.
* * H-Blank effects optimized (it fixes `world_map` example flickering).
* * SRAM code moved from EWRAM to ROM to avoid a No$gba crash.
*
*
* @section changelog_4_0_0 4.0.0
Expand Down
2 changes: 2 additions & 0 deletions butano/src/bn_hblank_effects_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,8 @@ void update()
}
}

BN_ASSERT(entries->uint32_entries_count <= 4, "Too much 32 bits entries: ", entries->uint32_entries_count);

external_data.visible_entries = visible_entries;
external_data.commit = true;
}
Expand Down
4 changes: 2 additions & 2 deletions docs/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h1>
<div class="m-block m-default">
<h3>Contents</h3>
<ul>
<li><a href="#changelog_4_0_1">4.0.1 (next release)</a></li>
<li><a href="#changelog_4_1_0">4.1.0 (next release)</a></li>
<li><a href="#changelog_4_0_0">4.0.0</a></li>
<li><a href="#changelog_3_3_0">3.3.0</a></li>
<li><a href="#changelog_3_2_1">3.2.1</a></li>
Expand All @@ -67,7 +67,7 @@ <h3>Contents</h3>
<li><a href="#changelog_0_1_0">0.1.0</a></li>
</ul>
</div>
<section id="changelog_4_0_1"><h2><a href="#changelog_4_0_1">4.0.1 (next release)</a></h2><p>SRAM code moved from EWRAM to ROM to avoid a No$gba crash.</p></section><section id="changelog_4_0_0"><h2><a href="#changelog_4_0_0">4.0.0</a></h2><ul><li>Affine backgrounds support. See <a href="group__affine__bg.html" class="m-doc">Affine backgrounds</a> and the <code>affine_bgs</code>, <code>mode_7</code> and <code>world_map</code> examples for more.</li><li>bn::hblank_effect_ptr renamed to <a href="classbn_1_1hbe__ptr.html" class="m-doc">bn::<wbr />hbe_ptr</a> (all child classes have been renamed too).</li><li>bn::sprite_affine_mat_attributes renamed to <a href="classbn_1_1affine__mat__attributes.html" class="m-doc">bn::<wbr />affine_mat_attributes</a>.</li><li>bn::bg_tiles_ptr renamed to <a href="classbn_1_1regular__bg__tiles__ptr.html" class="m-doc">bn::<wbr />regular_bg_tiles_ptr</a>.</li><li>bn::bg_tiles_item renamed to <a href="classbn_1_1regular__bg__tiles__item.html" class="m-doc">bn::<wbr />regular_bg_tiles_item</a>.</li><li>bn::affine_mat_scale_lut replaced with <a href="group__math.html#gad79a3d97fe687dfcb7c626b2ec3e7e19" class="m-doc">bn::<wbr />reciprocal_lut</a>.</li><li>bn::core::cpu_usage() and bn::core::vblank_usage() renamed to <a href="namespacebn_1_1core.html#a5c36ceb40cf617f8ffa442bbf15126c1" class="m-doc">bn::<wbr />core::<wbr />last_cpu_usage()</a> and <a href="namespacebn_1_1core.html#aace6487154c238af8d207e0e400f6fcf" class="m-doc">bn::<wbr />core::<wbr />last_vblank_usage()</a>.</li><li><a href="group__math.html#gae167fb45b236d70a84fc2b17810eaaf4" class="m-doc">bn::<wbr />lut_reciprocal()</a> added.</li><li><a href="namespacebn_1_1core.html#aed64f380e43b831c5b6b4602a508f811" class="m-doc">bn::<wbr />core::<wbr />current_cpu_usage()</a> added.</li><li><a href="https://github.com/rodri042/gba-link-connection">gba-link-connection</a> updated to v2.1.4.</li><li><a href="namespacebn_1_1hdma.html" class="m-doc">bn::<wbr />hdma</a> is disabled when needed, like before sleeping or before an assert screen.</li><li><a href="classbn_1_1regular__bg__tiles__item.html#a60fd48975d61ef83ba700e84a1183a8f" class="m-doc">bn::<wbr />regular_bg_tiles_item::<wbr />valid_tiles_count()</a> fixed.</li><li><a href="namespacebn.html#a850f005ae3a402328e48dfb60e5de6a4" class="m-doc">bn::<wbr />nullopt</a> documentation links fixed.</li></ul></section><section id="changelog_3_3_0"><h2><a href="#changelog_3_3_0">3.3.0</a></h2><ul><li>HDMA properly supported (now it works at less than 60fps). See <a href="namespacebn_1_1hdma.html" class="m-doc">bn::<wbr />hdma</a> and the <code>hdma_polygons</code> example for more.</li><li><a href="https://github.com/rodri042/gba-link-connection">gba-link-connection</a> remote timeout detection fixed.</li></ul></section><section id="changelog_3_2_1"><h2><a href="#changelog_3_2_1">3.2.1</a></h2><p><a href="classbn_1_1optional.html" class="m-doc">bn::<wbr />optional</a> build fix.</p></section><section id="changelog_3_2_0"><h2><a href="#changelog_3_2_0">3.2.0</a></h2><p><a href="classbn_1_1optional.html" class="m-doc">bn::<wbr />optional</a> is now constexpr.</p></section><section id="changelog_3_1_0"><h2><a href="#changelog_3_1_0">3.1.0</a></h2><ul><li><a href="classbn_1_1regular__bg__map__ptr.html#a397d70a0c80cf5c9ef2a1f99927b28be" class="m-doc">bn::<wbr />regular_bg_map_ptr::<wbr />tiles_offset()</a> and <a href="classbn_1_1regular__bg__map__ptr.html#a7528742121e00d8ea9993b71847cc4dd" class="m-doc">bn::<wbr />regular_bg_map_ptr::<wbr />palette_banks_offset()</a> methods added.</li><li>Allocated background tiles and maps commit fixed.</li></ul></section><section id="changelog_3_0_0"><h2><a href="#changelog_3_0_0">3.0.0</a></h2><p>Thanks to the awesome <a href="https://github.com/rodri042/gba-link-connection">gba-link-connection</a>, multiplayer support has been implemented! See <a href="namespacebn_1_1link.html" class="m-doc">bn::<wbr />link</a> and the <code>link</code> example for more.</p></section><section id="changelog_2_0_0"><h2><a href="#changelog_2_0_0">2.0.0</a></h2><ul><li>By removing some method overloads, lots of runtime asserts when creating resources have been removed.</li><li>bn::palette_bpp_mode has been renamed to <a href="group__color.html#ga297688ff852c5695452017a2622cb204" class="m-doc">bn::<wbr />bpp_mode</a> and <code><a href="group__color.html#ga297688ff852c5695452017a2622cb204" class="m-doc">bpp_<wbr />mode()</a></code> methods have been renamed to <code>bpp()</code>.</li><li>8 bits per pixel background tiles allocation fixed.</li></ul></section><section id="changelog_1_0_0"><h2><a href="#changelog_1_0_0">1.0.0</a></h2><ul><li>Regular maps bigger than 512x512 supported.</li><li>Division by 0 assert added.</li><li><a href="classbn_1_1regular__bg__item.html" class="m-doc">bn::<wbr />regular_bg_item</a> maximum tiles check added.</li><li><a href="classbn_1_1regular__bg__item.html" class="m-doc">bn::<wbr />regular_bg_item</a> generation options fixed.</li></ul></section><section id="changelog_0_4_0"><h2><a href="#changelog_0_4_0">0.4.0</a></h2><ul><li><code>btn</code> renamed to <code>bn</code>. No more API breaks will be made between minor releases after 1.0.0, promise.</li><li>Background tiles manager status can be printed in the log with <a href="namespacebn_1_1bg__tiles.html#ad5a2942ef2949f9df246367e55a8f46a" class="m-doc">bn::<wbr />bg_tiles::<wbr />log_status()</a>. This is done automatically when a non-optional background tiles allocation fails too.</li><li>Background regular maps manager status can be printed in the log with <a href="namespacebn_1_1bg__maps.html#ab9a11f9072c42e4843cecc10690ce1aa" class="m-doc">bn::<wbr />bg_maps::<wbr />log_status()</a>. This is done automatically when a non-optional regular background map allocation fails too.</li><li>Sprite tiles manager status can be printed in the log with <a href="namespacebn_1_1sprite__tiles.html#ac38355bc66b2f69750241c73662dcf6c" class="m-doc">bn::<wbr />sprite_tiles::<wbr />log_status()</a>. This is done automatically when a non-optional sprite tiles allocation fails too.</li><li>Color palettes managers status can be printed in the log with <a href="namespacebn_1_1bg__palettes.html#a34c88e1d5175821828bfa1a87f3d9a6e" class="m-doc">bn::<wbr />bg_palettes::<wbr />log_status()</a> and <a href="namespacebn_1_1sprite__palettes.html#a029d633f1be5d839af468a9c8e02b986" class="m-doc">bn::<wbr />sprite_palettes::<wbr />log_status()</a>. This is done automatically when a non-optional color palette allocation fails too.</li><li>Sprites destruction optimized.</li><li>Setters with an optional parameter added to some classes.</li><li>Optional components documentation fixed.</li><li>Other documentation improvements.</li></ul></section><section id="changelog_0_3_0"><h2><a href="#changelog_0_3_0">0.3.0</a></h2><ul><li>Sprites update performance improved up to 30% in Butano Fighter thanks to avoid rebuilding sprites list as much as possible.</li><li>Profiler can show the maximum measured ticks per entry.</li><li>Assets tools print output binaries size.</li></ul></section><section id="changelog_0_2_0"><h2><a href="#changelog_0_2_0">0.2.0</a></h2><ul><li>Performance improved up to 12% in Butano Fighter without <code>-flto</code> thanks to using less build translation units.</li><li>Documentation improved.</li></ul></section><section id="changelog_0_1_0"><h2><a href="#changelog_0_1_0">0.1.0</a></h2><p>First release.</p></section>
<section id="changelog_4_1_0"><h2><a href="#changelog_4_1_0">4.1.0 (next release)</a></h2><ul><li>H-Blank effects optimized (it fixes <code>world_map</code> example flickering).</li><li>SRAM code moved from EWRAM to ROM to avoid a No$gba crash.</li></ul></section><section id="changelog_4_0_0"><h2><a href="#changelog_4_0_0">4.0.0</a></h2><ul><li>Affine backgrounds support. See <a href="group__affine__bg.html" class="m-doc">Affine backgrounds</a> and the <code>affine_bgs</code>, <code>mode_7</code> and <code>world_map</code> examples for more.</li><li>bn::hblank_effect_ptr renamed to <a href="classbn_1_1hbe__ptr.html" class="m-doc">bn::<wbr />hbe_ptr</a> (all child classes have been renamed too).</li><li>bn::sprite_affine_mat_attributes renamed to <a href="classbn_1_1affine__mat__attributes.html" class="m-doc">bn::<wbr />affine_mat_attributes</a>.</li><li>bn::bg_tiles_ptr renamed to <a href="classbn_1_1regular__bg__tiles__ptr.html" class="m-doc">bn::<wbr />regular_bg_tiles_ptr</a>.</li><li>bn::bg_tiles_item renamed to <a href="classbn_1_1regular__bg__tiles__item.html" class="m-doc">bn::<wbr />regular_bg_tiles_item</a>.</li><li>bn::affine_mat_scale_lut replaced with <a href="group__math.html#gad79a3d97fe687dfcb7c626b2ec3e7e19" class="m-doc">bn::<wbr />reciprocal_lut</a>.</li><li>bn::core::cpu_usage() and bn::core::vblank_usage() renamed to <a href="namespacebn_1_1core.html#a5c36ceb40cf617f8ffa442bbf15126c1" class="m-doc">bn::<wbr />core::<wbr />last_cpu_usage()</a> and <a href="namespacebn_1_1core.html#aace6487154c238af8d207e0e400f6fcf" class="m-doc">bn::<wbr />core::<wbr />last_vblank_usage()</a>.</li><li><a href="group__math.html#gae167fb45b236d70a84fc2b17810eaaf4" class="m-doc">bn::<wbr />lut_reciprocal()</a> added.</li><li><a href="namespacebn_1_1core.html#aed64f380e43b831c5b6b4602a508f811" class="m-doc">bn::<wbr />core::<wbr />current_cpu_usage()</a> added.</li><li><a href="https://github.com/rodri042/gba-link-connection">gba-link-connection</a> updated to v2.1.4.</li><li><a href="namespacebn_1_1hdma.html" class="m-doc">bn::<wbr />hdma</a> is disabled when needed, like before sleeping or before an assert screen.</li><li><a href="classbn_1_1regular__bg__tiles__item.html#a60fd48975d61ef83ba700e84a1183a8f" class="m-doc">bn::<wbr />regular_bg_tiles_item::<wbr />valid_tiles_count()</a> fixed.</li><li><a href="namespacebn.html#a850f005ae3a402328e48dfb60e5de6a4" class="m-doc">bn::<wbr />nullopt</a> documentation links fixed.</li></ul></section><section id="changelog_3_3_0"><h2><a href="#changelog_3_3_0">3.3.0</a></h2><ul><li>HDMA properly supported (now it works at less than 60fps). See <a href="namespacebn_1_1hdma.html" class="m-doc">bn::<wbr />hdma</a> and the <code>hdma_polygons</code> example for more.</li><li><a href="https://github.com/rodri042/gba-link-connection">gba-link-connection</a> remote timeout detection fixed.</li></ul></section><section id="changelog_3_2_1"><h2><a href="#changelog_3_2_1">3.2.1</a></h2><p><a href="classbn_1_1optional.html" class="m-doc">bn::<wbr />optional</a> build fix.</p></section><section id="changelog_3_2_0"><h2><a href="#changelog_3_2_0">3.2.0</a></h2><p><a href="classbn_1_1optional.html" class="m-doc">bn::<wbr />optional</a> is now constexpr.</p></section><section id="changelog_3_1_0"><h2><a href="#changelog_3_1_0">3.1.0</a></h2><ul><li><a href="classbn_1_1regular__bg__map__ptr.html#a397d70a0c80cf5c9ef2a1f99927b28be" class="m-doc">bn::<wbr />regular_bg_map_ptr::<wbr />tiles_offset()</a> and <a href="classbn_1_1regular__bg__map__ptr.html#a7528742121e00d8ea9993b71847cc4dd" class="m-doc">bn::<wbr />regular_bg_map_ptr::<wbr />palette_banks_offset()</a> methods added.</li><li>Allocated background tiles and maps commit fixed.</li></ul></section><section id="changelog_3_0_0"><h2><a href="#changelog_3_0_0">3.0.0</a></h2><p>Thanks to the awesome <a href="https://github.com/rodri042/gba-link-connection">gba-link-connection</a>, multiplayer support has been implemented! See <a href="namespacebn_1_1link.html" class="m-doc">bn::<wbr />link</a> and the <code>link</code> example for more.</p></section><section id="changelog_2_0_0"><h2><a href="#changelog_2_0_0">2.0.0</a></h2><ul><li>By removing some method overloads, lots of runtime asserts when creating resources have been removed.</li><li>bn::palette_bpp_mode has been renamed to <a href="group__color.html#ga297688ff852c5695452017a2622cb204" class="m-doc">bn::<wbr />bpp_mode</a> and <code><a href="group__color.html#ga297688ff852c5695452017a2622cb204" class="m-doc">bpp_<wbr />mode()</a></code> methods have been renamed to <code>bpp()</code>.</li><li>8 bits per pixel background tiles allocation fixed.</li></ul></section><section id="changelog_1_0_0"><h2><a href="#changelog_1_0_0">1.0.0</a></h2><ul><li>Regular maps bigger than 512x512 supported.</li><li>Division by 0 assert added.</li><li><a href="classbn_1_1regular__bg__item.html" class="m-doc">bn::<wbr />regular_bg_item</a> maximum tiles check added.</li><li><a href="classbn_1_1regular__bg__item.html" class="m-doc">bn::<wbr />regular_bg_item</a> generation options fixed.</li></ul></section><section id="changelog_0_4_0"><h2><a href="#changelog_0_4_0">0.4.0</a></h2><ul><li><code>btn</code> renamed to <code>bn</code>. No more API breaks will be made between minor releases after 1.0.0, promise.</li><li>Background tiles manager status can be printed in the log with <a href="namespacebn_1_1bg__tiles.html#ad5a2942ef2949f9df246367e55a8f46a" class="m-doc">bn::<wbr />bg_tiles::<wbr />log_status()</a>. This is done automatically when a non-optional background tiles allocation fails too.</li><li>Background regular maps manager status can be printed in the log with <a href="namespacebn_1_1bg__maps.html#ab9a11f9072c42e4843cecc10690ce1aa" class="m-doc">bn::<wbr />bg_maps::<wbr />log_status()</a>. This is done automatically when a non-optional regular background map allocation fails too.</li><li>Sprite tiles manager status can be printed in the log with <a href="namespacebn_1_1sprite__tiles.html#ac38355bc66b2f69750241c73662dcf6c" class="m-doc">bn::<wbr />sprite_tiles::<wbr />log_status()</a>. This is done automatically when a non-optional sprite tiles allocation fails too.</li><li>Color palettes managers status can be printed in the log with <a href="namespacebn_1_1bg__palettes.html#a34c88e1d5175821828bfa1a87f3d9a6e" class="m-doc">bn::<wbr />bg_palettes::<wbr />log_status()</a> and <a href="namespacebn_1_1sprite__palettes.html#a029d633f1be5d839af468a9c8e02b986" class="m-doc">bn::<wbr />sprite_palettes::<wbr />log_status()</a>. This is done automatically when a non-optional color palette allocation fails too.</li><li>Sprites destruction optimized.</li><li>Setters with an optional parameter added to some classes.</li><li>Optional components documentation fixed.</li><li>Other documentation improvements.</li></ul></section><section id="changelog_0_3_0"><h2><a href="#changelog_0_3_0">0.3.0</a></h2><ul><li>Sprites update performance improved up to 30% in Butano Fighter thanks to avoid rebuilding sprites list as much as possible.</li><li>Profiler can show the maximum measured ticks per entry.</li><li>Assets tools print output binaries size.</li></ul></section><section id="changelog_0_2_0"><h2><a href="#changelog_0_2_0">0.2.0</a></h2><ul><li>Performance improved up to 12% in Butano Fighter without <code>-flto</code> thanks to using less build translation units.</li><li>Documentation improved.</li></ul></section><section id="changelog_0_1_0"><h2><a href="#changelog_0_1_0">0.1.0</a></h2><p>First release.</p></section>
</div>
</div>
</div>
Expand Down

0 comments on commit 9be5818

Please sign in to comment.