Skip to content

Commit

Permalink
examples: hdma_example improved
Browse files Browse the repository at this point in the history
  • Loading branch information
GValiente committed Aug 13, 2024
1 parent 071c509 commit 18e6c1e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
Binary file modified docs/examples_hdma_palette.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs_tools/images/examples_hdma_palette.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 4 additions & 6 deletions examples/hdma_palette/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,16 @@ int main()
for(int scanline = 0; scanline < bn::display::height(); ++scanline)
{
uint16_t* hdma_scanline_data = hdma_source_data + (scanline * colors_count);
int color_dec = (scanline + 1) % 32;
int red_reduction = (scanline + 1) % 32;

if(color_dec > 16)
if(red_reduction > 16)
{
color_dec = 32 - color_dec;
red_reduction = 32 - red_reduction;
}

for(bn::color color : bg_palette_item.colors_ref())
{
color.set_red(bn::max(color.red() - color_dec, 0));
color.set_green(bn::max(color.green() - color_dec, 0));
color.set_blue(bn::max(color.blue() - color_dec, 0));
color.set_red(bn::max(color.red() - red_reduction, 0));
*hdma_scanline_data = uint16_t(color.data());
++hdma_scanline_data;
}
Expand Down

0 comments on commit 18e6c1e

Please sign in to comment.