A good start

This commit is contained in:
Amrit Panesar committed 2016-10-19 00:23:03 -07:00
1 parent b02a670fbb
commit ad4461fde6
31 files changed
+2881

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
/**
arm-016-util.c
*/
#include "util.h"
void setColor(volatile unsigned char* fb, colour_t pixel, long x, long y, long pitch)
{
int pixel_offset = ( x * ( SCREEN_DEPTH >> 3 ) ) + ( y * pitch );
int r = (int)( pixel.r * 0xFF ) & 0xFF;
int g = (int)( pixel.g * 0xFF ) & 0xFF;
int b = (int)( pixel.b * 0xFF ) & 0xFF;
int a = (int)( pixel.a * 0xFF ) & 0xFF;
if( SCREEN_DEPTH == 32 )
{
/* Four bytes to write */
fb[ pixel_offset++ ] = r;
fb[ pixel_offset++ ] = g;
fb[ pixel_offset++ ] = b;
fb[ pixel_offset++ ] = a;
}
else if( SCREEN_DEPTH == 24 )
{
/* Three bytes to write */
fb[ pixel_offset++ ] = r;
fb[ pixel_offset++ ] = g;
fb[ pixel_offset++ ] = b;
}
else if( SCREEN_DEPTH == 16 )
{
/* Two bytes to write */
/* Bit pack RGB565 into the 16-bit pixel offset */
*(unsigned short*)&fb[pixel_offset] = ( (r >> 3) << 11 ) | ( ( g >> 2 ) << 5 ) | ( b >> 3 );
}
else
{
/* Palette mode. TODO: Work out a colour scheme for
packing rgb into an 8-bit palette! */
}
}
+33
View File
@@ -0,0 +1,33 @@
/**
arm-016-util.h
*/
#ifndef arm_016_util
#define arm_016_util
#define SCREEN_WIDTH 1920
#define SCREEN_HEIGHT 1080
#define SCREEN_DEPTH 24 /* 16 or 32-bit */
#define COLOUR_DELTA 0.05 /* Float from 0 to 1 incremented by this amount */
typedef struct {
float r;
float g;
float b;
float a;
} colour_t;
#define dickbuttHeight 352
#define dickbuttWidth 624
#define dickbuttBytes 658945
extern const int dickbutt[dickbuttBytes];
extern void setColor(volatile unsigned char* fb, colour_t pixel, long x, long y, long pitch);
#endif