123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- #include <fxcg/display.h>
- #include <fxcg/file.h>
- #include <fxcg/keyboard.h>
- #include <fxcg/system.h>
- #include <fxcg/misc.h>
- #include <fxcg/app.h>
- #include <fxcg/serial.h>
- #include <fxcg/rtc.h>
- #include <fxcg/heap.h>
- #include <string.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include "graphicsProvider.hpp"
- const short empty[18] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- int PrintMiniFix( int x, int y, const char*Msg, const int flags, const short color, const short bcolor )
- {
- int i = 0, dx;
- unsigned short width;
- void*p;
- while ( Msg[ i ] )
- {
- if( Msg[i] == 9) {
- drawLine(x, y+24+7, x+11, y+24+7, color);
- drawLine(x, y+24+8, x+11, y+24+8, color);
- x+=12;
- i++;
- continue;
- } else if( Msg[i] == 31) {
-
- int tx = x+2, ty=y;
- PrintMini(&tx, &ty, (unsigned char*)"\xe6\xaa", 0, 0xFFFFFFFF, 0, 0, color, bcolor, 1, 0);
- x+=12;
- i++;
- continue;
- } else p = GetMiniGlyphPtr( Msg[ i ], &width );
- dx = ( 12 - width ) / 2;
- if ( dx > 0 )
- {
- PrintMiniGlyph( x, y, (void*)empty, flags, dx, 0, 0, 0, 0, color, bcolor, 0 );
- }
-
- else dx = 0;
- PrintMiniGlyph( x + dx, y, p, flags, width, 0, 0, 0, 0, color, bcolor, 0 );
- if ( width + dx < 12 )
- {
- PrintMiniGlyph( x + width + dx, y, (void*)empty, flags, 12 - width - dx, 0, 0, 0, 0, color, bcolor, 0 );
- }
- x += 12;
- i++;
- }
- return x;
- }
- void plot(int x0, int y0,unsigned short color) {
- unsigned short* VRAM = (unsigned short*)0xA8000000;
- VRAM += (y0*LCD_WIDTH_PX + x0);
- *VRAM=color;
- }
- void drawRectangle(int x, int y, int width, int height, unsigned short color){
- unsigned short*VRAM = (unsigned short*)0xA8000000;
- VRAM+=(y*384)+x;
- while(height--){
- int i=width;
- while(i--){
- *VRAM++ = color;
- }
- VRAM+=384-width;
- }
- }
- void drawLine(int x1, int y1, int x2, int y2, int color) {
- signed char ix;
- signed char iy;
-
-
- int delta_x = (x2 > x1?(ix = 1, x2 - x1):(ix = -1, x1 - x2)) << 1;
- int delta_y = (y2 > y1?(iy = 1, y2 - y1):(iy = -1, y1 - y2)) << 1;
-
- plot(x1, y1, color);
- if (delta_x >= delta_y) {
- int error = delta_y - (delta_x >> 1);
- while (x1 != x2) {
- if (error >= 0) {
- if (error || (ix > 0)) {
- y1 += iy;
- error -= delta_x;
- }
- }
- x1 += ix;
- error += delta_y;
- plot(x1, y1, color);
- }
- } else {
- int error = delta_x - (delta_y >> 1);
- while (y1 != y2) {
- if (error >= 0) {
- if (error || (iy > 0)) {
- x1 += ix;
- error -= delta_y;
- }
- }
- y1 += iy;
- error += delta_x;
- plot(x1, y1, color);
- }
- }
- }
- void CopySpriteMasked(unsigned short* data, int x, int y, int width, int height, unsigned short maskcolor) {
- unsigned short* VRAM = (unsigned short*)0xA8000000;
- VRAM += (LCD_WIDTH_PX*y + x);
- while(height--) {
- int i=width;
- while(i--){
- if(*data!=maskcolor) {
- *(VRAM++) = *(data++);
- } else {
- ++VRAM;
- ++data;
- }
- }
- VRAM += (LCD_WIDTH_PX-width);
- }
- }
- static const unsigned char logoB[]={
- 0, 6, 6, 24,
- 6, 12, 6, 6,
- 6, 30, 6, 6,
- 18, 12, 6, 24,
- 24, 12, 12, 6,
- 36, 18, 6, 18,
- 48, 12, 6, 18,
- 60, 12, 6, 18,
- 54, 30, 6, 6,
- 48, 36, 6, 6,
- 72, 30, 6, 6 };
- static const unsigned char logoO[]={
- 84, 0, 6, 6,
- 84, 12, 6, 24,
- 96, 12, 6, 24,
- 102, 12, 12, 6,
- 114, 18, 6, 18,
- 120, 12, 12, 6,
- 132, 18, 6, 18 };
- void drawtnyimLogo(int x, int y) {
- int i;
- for(i=0;i<11*4;i+=4)
- drawRectangle(x+logoB[i], y+logoB[i+1], logoB[i+2], logoB[i+3], COLOR_BLACK);
- for(i=0;i<7*4;i+=4)
- drawRectangle(x+logoO[i], y+logoO[i+1], logoO[i+2], logoO[i+3], TNYIM_ORANGE);
- }
- void printCentered(unsigned char* text, int y, int FGC, int BGC) {
- int len = strlen((char*)text);
- int x = LCD_WIDTH_PX/2-(len*18)/2;
- int cur = 0;
- while(cur<len) {
- PrintCXY(x, y, &text[cur], 0x40, -1, FGC, BGC, 1, 0 );
- x=x+18;
- cur++;
- }
- }
|