Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ This project isn’t just a chess engine—it’s a blueprint for building lean,

## License
MicroChess is licensed under the MIT License. See the [LICENSE](https://github.com/ripred/MicroChess/blob/main/LICENSE) file for details.

## Bug Fixes

- **LED Strip King Colors**: Kings were sometimes displayed with incorrect LED colors
because the color lookup indexed beyond the end of the color table. The index
now wraps correctly so both white and black kings use the right colors.
7 changes: 6 additions & 1 deletion led_strip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ void set_led_strip(index_t const flash /* = -1 */)
static index_t constexpr values_per_led = index_t(3);
static index_t constexpr values_per_side = index_t(sizeof(piece_colors) / 2);

clr = (vars.type * values_per_led) + (vars.side * values_per_side);
// There are only six color definitions per side in piece_colors.
// Piece type values range from 0 (Empty) to 6 (King) so using the
// raw type value would index beyond the table for Kings.
// Mod the type by six to keep the index within bounds.
clr = ((vars.type % 6) * values_per_led) +
(vars.side * values_per_side);

leds[vars.led_index] = (Empty == vars.type) ?
// empty spots
Expand Down
Loading