-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSelection.cpp
35 lines (31 loc) · 1.16 KB
/
Selection.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "Selection.h"
#include "spritebank.h"
/*--------------------------------------------------------------*/
Selection::Selection( uint8_t *bitmapChecked, uint8_t *bitmapUnchecked, const uint8_t bitmapWidth, const uint8_t bitmapOffsetX, const uint8_t selection ) :
_bitmapSelected( bitmapChecked ),
_bitmapUnselected( bitmapUnchecked ),
_bitmapWidth( bitmapWidth ),
_bitmapOffsetX( bitmapOffsetX ),
_selection( selection )
{
}
/*--------------------------------------------------------------*/
// Returns the selection overlay for ( x, y ) considering the
// selected item.
uint8_t Selection::getOverlayPixels( const uint8_t x, const uint8_t y )
{
uint8_t pixels = 0;
uint8_t *bitmap = ( ( y >> 1 ) == _selection ) ? _bitmapSelected : _bitmapUnselected;
if ( ( x >= _bitmapOffsetX ) && ( x < _bitmapOffsetX + _bitmapWidth ) )
{
if ( ( y & 0x01 ) == 0x00 )
{
pixels |= pgm_read_byte( bitmap + x - _bitmapOffsetX );
}
else
{
pixels |= pgm_read_byte( bitmap + x - _bitmapOffsetX + _bitmapWidth );
}
}
return( pixels );
}