diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/lcd.c | 73 |
1 files changed, 32 insertions, 41 deletions
diff --git a/firmware/drivers/lcd.c b/firmware/drivers/lcd.c index 8a6207bc87..80e46adbdf 100644 --- a/firmware/drivers/lcd.c +++ b/firmware/drivers/lcd.c @@ -488,55 +488,46 @@ void lcd_bitmap (unsigned char *src, int x, int y, int nx, int ny, bool clear) { unsigned char *dst; - unsigned char *dst2 = &display[x][y/8]; + unsigned char *dst2; unsigned int data, mask, mask2, mask3, mask4; - int shift = y & 7; + int shift; + int nny, _nnx = x, _nny = y; - ny += shift; - - /* Calculate bit masks */ - mask4 = ~(0xfe << ((ny-1) & 7)); - if (clear) + for (nny = ny; nny > 0; nny -= 8, _nny += 8) { - mask = ~(0xff << shift); - mask2 = 0; - mask3 = ~mask4; - if (ny <= 8) - mask3 |= mask; - } - else - mask = mask2 = mask3 = 0xff; + x = _nnx; y = _nny; ny = 8; - /* Loop for each column */ - for (x = 0; x < nx; x++) - { - dst = dst2; - dst2 += LCD_HEIGHT/8; - data = 0; - y = 0; + dst2 = &display[x][y/8]; + shift = y & 7; + + ny += shift; - if (ny > 8) + /* Calculate bit masks */ + mask4 = ~(0xfe << ((ny-1) & 7)); + if (clear) { - /* First partial row */ - data = *src++ << shift; - *dst = (*dst & mask) ^ data; - data >>= 8; - dst++; - - /* Intermediate rows */ - for (y = 8; y < ny-8; y += 8) - { - data |= *src++ << shift; - *dst = (*dst & mask2) ^ data; - data >>= 8; - dst++; - } + mask = ~(0xff << shift); + mask2 = 0; + mask3 = ~mask4; + if (ny <= 8) + mask3 |= mask; } + else + mask = mask2 = mask3 = 0xff; + + /* Loop for each column */ + for (x = 0; x < nx; x++) + { + dst = dst2; + dst2 += LCD_HEIGHT/8; + data = 0; + y = 0; - /* Last partial row */ - if (y + shift < ny) - data |= *src++ << shift; - *dst = (*dst & mask3) ^ (data & mask4); + /* Last partial row */ + if (y + shift < ny) + data |= *src++ << shift; + *dst = (*dst & mask3) ^ (data & mask4); + } } } |