From dbbb7d4ca12c21c84af2f72f7c75ce7a3559dcad Mon Sep 17 00:00:00 2001 From: hackbard <hackbard@sage.physik.uni-augsburg.de> Date: Fri, 14 Sep 2007 16:17:42 +0200 Subject: [PATCH] display extended (untested!) --- betty/display.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++--- betty/display.h | 6 +++- 2 files changed, 78 insertions(+), 5 deletions(-) diff --git a/betty/display.c b/betty/display.c index ce8fd7c..a439fcd 100644 --- a/betty/display.c +++ b/betty/display.c @@ -50,7 +50,7 @@ void display_fill_screen(u8 fill) { } for(page=0;page<DISPLAY_PAGE_MAX;page++) { - DISPLAY_SET_C_ADDR(0); + DISPLAY_SET_COL_ADDR(0); DISPLAY_SET_PAGE_ADDR(page); for(width=0;width<DISPLAY_DIMX;width++) { DISPLAY_DATA=buf[0]; @@ -99,7 +99,7 @@ void display_load_logo(u8 *src) { s=default_logo; for(page=0;page<DISPLAY_PAGE_MAX;page++) { - DISPLAY_SET_C_ADDR(0); + DISPLAY_SET_COL_ADDR(0); DISPLAY_SET_PAGE_ADDR(page); for(width=0;width<DISPLAY_DIMX;width++) { DISPLAY_DATA=*s++; @@ -128,7 +128,7 @@ void display_draw_rectangle(u8 x,u8 y,u8 w,u8 h,u8 fill,u8 alpha) { if(rmax>y+h) rmax=y+h; for(col=x;col<x+w;col++) { - DISPLAY_SET_C_ADDR(col); + DISPLAY_SET_COL_ADDR(col); d[0]=DISPLAY_DATA; // dummy read (p.16) d[0]=DISPLAY_DATA; d[1]=DISPLAY_DATA; @@ -145,16 +145,85 @@ void display_draw_rectangle(u8 x,u8 y,u8 w,u8 h,u8 fill,u8 alpha) { d[0]|=((c>>1)&1)<<row; d[1]|=(c&1)<<row; } - DISPLAY_SET_C_ADDR(col); + DISPLAY_SET_COL_ADDR(col); DISPLAY_DATA=b[0]; DISPLAY_DATA=b[1]; } + h-=(rmax-y); + y=rmax; + } +} + +void display_draw_font(u8 x,u8 y,u8 *font,u8 fill,u8 alpha) { + + u8 page,col,row,rmax,cnt,left; + u8 d[2]; + int ca,cb; + u8 a,b,c; // c = a over b + + left=8; + + a=fill&0x03; + ca=0; + for(cnt=0;cnt<a;cnt++) // contribution of a: alpha*a + ca+=alpha; + + for(page=(y>>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<x+8;col++) { + DISPLAY_SET_COL_ADDR(col); + d[0]=DISPLAY_DATA; // dummy read (p.16) + d[0]=DISPLAY_DATA; + d[1]=DISPLAY_DATA; + rf=0; + for(row=y;row<rmax;row++) { + // contribution of b: (255-alpha)*b + b=display_m2i(d,row); + cb=0; + for(cnt=0;cnt<b;cnt++) + cb+=(255-alpha); + // finally there is c + if((font[cf]>>row)&1) { + c=(ca+cb)>>8; + d[0]&=~(1<<row); + d[1]&=~(1<<row); + d[0]|=((c>>1)&1)<<row; + d[1]|=(c&1)<<row; + } + rf+=1; + } + DISPLAY_SET_COL_ADDR(col); + DISPLAY_DATA=b[0]; + DISPLAY_DATA=b[1]; + cf+=1; + } + left-=(rmax-y); y=rmax; } } void display_draw_buf(u8 x,u8 y,u8 w,u8 h,u8 *buf,u8 alpha) { + u8 page,col,row,rmax,cnt; + u8 d[2]; + int ca,cb; + u8 a,b,c; + + for(page=(y>>3);page<=((y+h)>>3);page++) { + DISPLAY_SET_PAGE_ADDR(page); + for(col=x;col<x+w;col++) { + DISPLAY_SET_COL_ADDR(col); + d[0]=DISPLAY_DATA; + d[0]=DISPLAY_DATA; + d[1]=DISPLAY_DATA; + for(row=y;row<rmax;row++) { + } + } + } } void display_bl_init(void) { diff --git a/betty/display.h b/betty/display.h index df371ac..b10835a 100644 --- a/betty/display.h +++ b/betty/display.h @@ -24,7 +24,7 @@ #define DISPLAY_RAM_CONTENT (DISPLAY_PAGE_MAX*DISPLAY_COL_MAX*2) /* display cmds */ -#define DISPLAY_SET_C_ADDR(c) DISPLAY_CMD=(0x00|((c)&0x0f)); \ +#define DISPLAY_SET_COL_ADDR(c) DISPLAY_CMD=(0x00|((c)&0x0f)); \ DISPLAY_CMD=(0x10|(((c)&0x70)>>4)) #define DISPLAY_SET_MASTER DISPLAY_CMD=0x18 #define DISPLAY_SET_SLAVE DISPLAY_CMD=0x19 @@ -94,6 +94,10 @@ DISPLAY_CMD=(c) #define DISPLAY_EXTENDED_FEATURES DISPLAY_CMD=0xf0 +/* experimental cmds */ +#define DISPLAY_SET_READ_MODIFY_WRITE DISPLAY_CMD=0xe0; +#define DISPLAY_UNSET_READ_MODIFY_WRITE DISPLAY_CMD=0xee; + /* display api specific defines */ #define DISPLAY_FILL_W 0x00 #define DISPLAY_FILL_LG 0x01 -- 2.39.5