00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "libg15render.h"
00020
00028 int
00029 g15r_getPixel (g15canvas * canvas, unsigned int x, unsigned int y)
00030 {
00031 if (x >= G15_LCD_WIDTH || y >= G15_LCD_HEIGHT)
00032 return 0;
00033
00034 unsigned int pixel_offset = y * G15_LCD_WIDTH + x;
00035 unsigned int byte_offset = pixel_offset / BYTE_SIZE;
00036 unsigned int bit_offset = 7 - (pixel_offset % BYTE_SIZE);
00037
00038 return (canvas->buffer[byte_offset] & (1 << bit_offset)) >> bit_offset;
00039 }
00040
00049 void
00050 g15r_setPixel (g15canvas * canvas, unsigned int x, unsigned int y, int val)
00051 {
00052 if (x >= G15_LCD_WIDTH || y >= G15_LCD_HEIGHT)
00053 return;
00054
00055 unsigned int pixel_offset = y * G15_LCD_WIDTH + x;
00056 unsigned int byte_offset = pixel_offset / BYTE_SIZE;
00057 unsigned int bit_offset = 7 - (pixel_offset % BYTE_SIZE);
00058
00059 if (canvas->mode_xor)
00060 val ^= g15r_getPixel (canvas, x, y);
00061 if (canvas->mode_reverse)
00062 val = !val;
00063
00064 if (val)
00065 canvas->buffer[byte_offset] =
00066 canvas->buffer[byte_offset] | 1 << bit_offset;
00067 else
00068 canvas->buffer[byte_offset] =
00069 canvas->buffer[byte_offset] & ~(1 << bit_offset);
00070
00071 }
00072
00079 void
00080 g15r_clearScreen (g15canvas * canvas, int color)
00081 {
00082 memset (canvas->buffer, (color ? 0xFF : 0), G15_BUFFER_LEN);
00083 }
00084
00090 void
00091 g15r_initCanvas (g15canvas * canvas)
00092 {
00093 memset (canvas->buffer, 0, G15_BUFFER_LEN);
00094 canvas->mode_cache = 0;
00095 canvas->mode_reverse = 0;
00096 canvas->mode_xor = 0;
00097 #ifdef TTF_SUPPORT
00098 if (FT_Init_FreeType (&canvas->ftLib))
00099 printf ("Freetype couldnt initialise\n");
00100 #endif
00101 }