Rev 3 | Rev 7 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3 | Rev 6 | ||
|---|---|---|---|
| Line 71... | Line 71... | ||
| 71 | abs (T x) |
71 | abs (T x) |
| 72 | { |
72 | { |
| 73 | return x < 0 ? -x : x; |
73 | return x < 0 ? -x : x; |
| 74 | } |
74 | } |
| 75 | 75 | ||
| 76 | - | ||
| 77 | - | ||
| 78 | } |
76 | } |
| 79 | // provided to allow a destructor to destroy something not deleted |
77 | // provided to allow a destructor to destroy something not deleted |
| 80 | // this is only OK because destructors shouldnt be needed |
78 | // this is only OK because destructors shouldnt be needed |
| - | 79 | void |
|
| 81 | void operator delete(void * data, unsigned int f) |
80 | operator delete (void *data, unsigned int f) |
| 82 | { |
81 | { |
| 83 | (void)data; |
82 | (void) data; |
| 84 | (void)f; |
83 | (void) f; |
| 85 | } |
84 | } |
| 86 | 85 | ||
| 87 | // provided to implement an "error handler" on pure virtual |
86 | // provided to implement an "error handler" on pure virtual |
| - | 87 | extern "C" void |
|
| 88 | extern "C" void __cxa_pure_virtual() |
88 | __cxa_pure_virtual () |
| 89 | { |
89 | { |
| 90 | while(1); |
90 | while (1) |
| - | 91 | ; |
|
| 91 | } |
92 | } |
| 92 | 93 | ||
| 93 | display_t::display_t (int const width, int const height, int const ramwidth, |
94 | display_t::display_t (int const width, int const height, int const ramwidth, |
| 94 | uint8_t *const data) : |
95 | uint8_t *const data) : |
| 95 | m_width (width), m_height (height), m_ramwidth (ramwidth), m_cursor_x (0), m_cursor_y ( |
96 | m_width (width), m_height (height), m_ramwidth (ramwidth), m_cursor_x (0), m_cursor_y ( |
| 96 | 0), m_rotation (0), m_data (data) |
97 | 0), m_rotation (0), m_data (data) |
| 97 | { |
98 | { |
| 98 | } |
99 | } |
| 99 | 100 | ||
| 100 | display_t::~display_t() |
101 | display_t::~display_t () |
| 101 | { |
102 | { |
| 102 | 103 | ||
| 103 | } |
104 | } |
| 104 | 105 | ||
| 105 | void |
106 | void |
| Line 369... | Line 370... | ||
| 369 | 370 | ||
| 370 | } |
371 | } |
| 371 | 372 | ||
| 372 | // clear everything |
373 | // clear everything |
| 373 | void |
374 | void |
| 374 | display_t::clearDisplay (void) |
375 | display_t::clearDisplay (colour_t colour) |
| - | 376 | { |
|
| - | 377 | memset (m_data, colour == WHITE ? 255 : 0, dataSize (m_width, m_height)); |
|
| - | 378 | } |
|
| - | 379 | ||
| - | 380 | void display_t::drawRectangle (int16_t x1, int16_t y1, int16_t x2, int16_t y2, |
|
| - | 381 | colour_t color) |
|
| 375 | { |
382 | { |
| - | 383 | for (int16_t x = x1; x <= x2; x++) |
|
| - | 384 | for (int16_t y = y1; y < y2; y++) |
|
| - | 385 | { |
|
| - | 386 | switch (color) |
|
| - | 387 | { |
|
| - | 388 | case BLACK: |
|
| - | 389 | m_data[x + (y / 8) * m_width] &= ~(1 << (y & 7)); |
|
| - | 390 | break; |
|
| - | 391 | ||
| - | 392 | default: |
|
| - | 393 | case WHITE: |
|
| 376 | memset (m_data, 0, dataSize (m_width, m_height)); |
394 | m_data[x + (y / 8) * m_width] |= (1 << (y & 7)); |
| - | 395 | break; |
|
| - | 396 | ||
| - | 397 | case INVERT: |
|
| - | 398 | m_data[x + (y / 8) * m_width] ^= (1 << (y & 7)); |
|
| - | 399 | break; |
|
| - | 400 | } |
|
| - | 401 | } |
|
| 377 | } |
402 | } |
| 378 | 403 | ||
| 379 | /* using Bresenham draw algorithm */ |
404 | /* using Bresenham draw algorithm */ |
| 380 | void |
405 | void |
| 381 | display_t::drawLine (int16_t x1, int16_t y1, int16_t x2, int16_t y2, |
406 | display_t::drawLine (int16_t x1, int16_t y1, int16_t x2, int16_t y2, |