for(... ; i < h; ...){
d = &a[offset];
w = width - (offset << 1);
if(w && ...)
... |
*d++ = color; *wd++ = wcolor; *(uint16_t *)d = color; /* write the last 16-bit word */ |
for (int i = 0; i < 10; i++){
for (int j = 0; j < 10; j++){
drawPixel(i, j, bitmap++):
}
}
__inline void drawPixel(uint16_t Xpos, uint16_t Ypos, uint16_t color) {
volatile uint16_t *pLCDbuf = (uint16_t *) LCD_VRAM_BASE_ADDR; /* LCD buffer start address */
pLCDbuf[Ypos * GLCD_X_SIZE + Xpos] = color;
} |
uint16_t *screen;
uint16_t linesize; /* width in pixels of a line */
uint16_t x, y; /* x and y position of box */
uint16_t w, h; /* box width and height */
uint16_t color; /* color of box */
uint16_t *a; /* precalculated address of starting top/left corner */
uint16_t *d; /* destination */
screen = (uint16_t *)LCD_VRAM_BASE_ADDR; /* this is what I usually call the screen base address */
linesize = GLCD_X_SIZE;
x = 17;
y = 33;
w = 50; /* width of our box */
h = 10; /* height of our box */
a = &screen[y * linesize + x]; /* get address of the top/right corner on of our 'box' on screen */
for (int i = 0; i < h; i++){
d = a; /* point d to left side of box */
for(int j = 0; j < w; j++)
{
*d++ = color;
}
a += linesize; /* advance to next line */
} |
loop: subsr2,r2,#1; decrement width counter, update condition codes (takes 1 clock cycle) strhr0,[r1],#2; store color (takes one clock cycle) bneloop; go round loop (2 clock cycles) |
uint32_t wcolor;
uint32_t *wd;
wcolor = (color << 16) | color;
uint16_t ww;
ww = w >> 1; /* width / 2 */
w &= 1; /* keep only odd-bit of w */
for (int i = 0; i < h; i++){
d = a; /* point d to left side of box */
if(w && (2 & (uint32_t) a)) /* if w is 1 and a is not on a 32-bit boundary */
{
*d++ = color;
w = 0;
}
wd = (uint32_t *)d;
for(int j = 0; j < ww; j++)
{
*wd++ = wcolor;
}
if(w) /* if we forgot to write the 16-bit word... */
{
*(uint16_t *)d = color; /* write the last 16-bit word */
}
a += linesize; /* advance to next line */
} |
loop: subsr2,r2,#1; decrement width counter, update condition codes (1 clk) strr0,[r1],#4; store two colors (1 clk) bneloop; go round loop (2 clk) |
loop: subsr2,r2,#1; decrement width counter and set condition code (1 clk) strr0,[r1,#4]; store two colors at address d + 4 (1 clk) strr0,[r1,#8]; store two colors at address d + 8 (1 clk) strr0,[r1,#12]; store two colors at address d + 12 (1 clk) strr0,[r1],#16; store two colors at address d, then d = d + 16 (1 clk) bneloop; go round loop (2 clk) |
for (int i = 0; i < 10; i++){
for (int j = 0; j < 10; j++){
drawPixel(i, j, bitmap++):
}
}
__inline void drawPixel(uint16_t Xpos, uint16_t Ypos, uint16_t color) {
volatile uint16_t *pLCDbuf = (uint16_t *) LCD_VRAM_BASE_ADDR; /* LCD buffer start address */
pLCDbuf[Ypos * GLCD_X_SIZE + Xpos] = color;
}
|
for (int i = 0; i < 10; i++){
for (int j = 0; j < 10; j++){
line[j] = bitmap++;
}
//and then somehow write the whole line to pLCDbuf[]???
}
actually no, Im confused |
void rbox(void *picture, int32_t dstx, int32_t dsty, int32_t width, int32_t height, int32_t radius)
{
int32_t dx, sx, ex;
int32_t save_x;
int32_t srcx, srcy;
...
for(srcy = 0; srcy < height; srcy++)
{
dx = calcx(radius, srcy, height);
sx = dx;
ex = width - dx;
save_x = dstx;
dstx += sx;
for(srcx = sx; srcx < ex; srcx++)
{
copypixel(picture,srcx,srcy,dstx++,dsty);
}
dstx = save_x;
dsty++;
}
} |
const uint32_t *ws;
uint32_t *wd;
const uint16_t *hs;
uint16_t *hd;
if(s < e && length & 1)
{
*hd++ = *hs++;
}
length = length >> 1;
wd = (uint32_t *)hd;
ws = (uint32_t *)hs;
while(s < e)
{
*wd++ = *ws++;
}
|
Bool GLCD_checkBresenhamCorner(uint16_t h, uint16_t k, uint16_t r,
uint16_t which, uint16_t xC, uint16_t yC) {
int x = 0;
int y = r;
int p = (3 - (2 * r));
do {
switch (which) {
case 1: {//Testing if its outside the top left corner
if (xC <= h - x && yC <= k - y) {
return 0;
} else if (xC <= h - y && yC <= k - x) {
return 0;
}
break;
}
case 2: {//Testing if its outside the top right corner
if (xC >= h + y && yC <= k - x) {
return 0;
} else if (xC >= h + x && yC <= k - y) {
return 0;
}
break;
}
case 3: {//Testing if its outside the bottom right corner
if (xC >= h + x && yC >= k + y) {
return 0;
} else if (xC >= h + y && yC >= k + x) {
return 0;
}
break;
}
case 4: {//Testing if its outside the bottom left corner
if (xC <= h - y && yC >= k + x) {
return 0;
} else if (xC <= h - x && yC >= k + y) {
return 0;
}
break;
}
}
x++;
if (p < 0)
p += ((4 * x) + 6);
else {
y--;
p += ((4 * (x - y)) + 10);
}
} while (x <= y);
return 1;
}
void GLCD_displayBitmapInCirle(uint16_t x, uint16_t y, uint16_t w, uint16_t h,
uint16_t r, uint16_t * bitmap) {
uint16_t atx = 0, aty = 0;
uint16_t j = 0;
uint16_t k = 0;
uint16_t index = 0;
for (k = 0; k < h; k++) {
for (j = 0; j < w; j++) {
atx = x + j;
aty = y + k;
if (atx <= x + r && aty <= y + r) { //is it in the top left corner
if (GLCD_checkBresenhamCorner(x + r, y + r, r, 1, atx, aty)
== 1) {
GLCD_SetPixel_16bpp(atx, aty, bitmap[index]);
}
} else if (atx >= x + w - r && aty <= y + r) { //is it in the top right corner
if (GLCD_checkBresenhamCorner(x + w - r, y + r, r, 2, atx, aty)
== 1) {
GLCD_SetPixel_16bpp(atx, aty, bitmap[index]);
}
} else if (atx >= x + w - r && aty >= y + h - r) { //is it in the bottom right corner
if (GLCD_checkBresenhamCorner(x + w - r, y + h - r, r, 3, atx,
aty) == 1) {
GLCD_SetPixel_16bpp(atx, aty, bitmap[index]);
}
} else if (atx <= x + r && aty >= y + h - r) { //is it in the bottom left corner
if (GLCD_checkBresenhamCorner(x + r, y + h - r, r, 4, atx, aty)
== 1) {
GLCD_SetPixel_16bpp(atx, aty, bitmap[index]);
}
} else { //its not in a corner so draw it
GLCD_SetPixel_16bpp(atx, aty, bitmap[index]);
}
index++;
}
}
x++;
}
|