X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Farm.git;a=blobdiff_plain;f=betty%2Fdisplay.c;h=46e8480a1e881cb698c67af4f21967fa04b539be;hp=2da19efe9ffa8f4ba42d32bd89c5339c369cfa13;hb=HEAD;hpb=96c6e10b97b3cce49a3c2090108ea29d23ec3950 diff --git a/betty/display.c b/betty/display.c index 2da19ef..46e8480 100644 --- a/betty/display.c +++ b/betty/display.c @@ -7,14 +7,18 @@ /* * some comments on alpha blending! + * ################################ * - * ... - * + * if c is the result of layer a over layer b with opacity alpha: + * + * c=alpha*a+(1-alpha)*b and if alpha is a byte (0-255) + * => c=alpha*a+(255-alpha)*b + * */ #include "display.h" -#include "system.h" -#include "default_logo.h" + +// debug #include "uart.h" /* @@ -46,7 +50,7 @@ void display_fill_screen(u8 fill) { } for(page=0;page>r)&1)<<1)|(((m)[1]>>r)&1)) - int c,r,rmax; - u8 p,spage,epage; - u8 b[2],a[2]; // c = a over b => c=alpha*a+(1-alpha)*b +void display_draw_rectangle(u8 x,u8 y,u8 w,u8 h,u8 fill,u8 alpha) { - a[0]=0; - a[1]=0; - switch(fill) { - case DISPLAY_FILL_LG: - a[1]=1; - break; - case DISPLAY_FILL_DG: - a[0]=1; - break; - case DISPLAY_FILL_B: - a[0]=1; - a[1]=1; - case DISPLAY_FILL_W: - default: - break; + u8 page,col,row,rmax,cnt; + u8 d[2]; + int ca,cb; + u8 a,b,c; // c = a over b + + a=fill&0x03; + ca=0; + for(cnt=0;cnt>3);page<=((y+h)>>3);page++) { // page = y/8 + DISPLAY_SET_PAGE_ADDR(page); + rmax=(page+1)<<3; // row max + if(rmax>y+h) + rmax=y+h; + for(col=x;col>8; + d[0]&=~(1<>1)&1)<>3; // start page = y/8 - epage=(y+h)>>3; // end page (y+h)/8 - - for(p=spage;p<=epage;p++) { - DISPLAY_SET_PAGE_ADDR(p); - for(c=x;cy+h?y+h:y+8; - for(r=y;r>8; + buf[0]&=~(1<>1]>>row)&1) { + c[cnt]&=~(1<>1)&1)<>3);page<=((y+8)>>3);page++) { // page = y/8 + DISPLAY_SET_PAGE_ADDR(page); + rmax=(page+1)<<3; // row max + if(rmax>y+left) + rmax=y+left; + cf=0; + for(col=x;col>row)&1) { + c=(ca+cb)>>8; + d[0]&=~(1<>1)&1)<