From: hackbard Date: Sun, 16 Sep 2007 14:19:55 +0000 (+0200) Subject: alpha blending X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=74be977af05343de9ebaf9f6358bf57e499a8044;p=my-code%2Farm.git alpha blending --- diff --git a/betty/Makefile b/betty/Makefile index 28184c3..4d2a1aa 100644 --- a/betty/Makefile +++ b/betty/Makefile @@ -11,7 +11,7 @@ CROSS_OBJCOPY = $(ARCH)-objcopy CROSS_OPTS = -mcpu=arm7tdmi-s CROSS_CFLAGS = $(CROSS_OPTS) -Wall -Os CROSS_ASLAGS = $(CROSS_OPTS) --gstabs -CROSS_RAM_LDFLAGS = -Tlpc2220_ram.ld -nostartfiles -nostdlib +CROSS_RAM_LDFLAGS = -Tlpc2220_ram.ld -nostartfiles -nostdlib CROSS_ROM_LDFLAGS = -Tlpc2220_rom.ld -nostartfiles -nostdlib # build objects diff --git a/betty/betty.c b/betty/betty.c index 8d7ce84..093232b 100644 --- a/betty/betty.c +++ b/betty/betty.c @@ -14,13 +14,33 @@ #define cc1100_init spi1_init(8,SPI_MASTER,8) +void display_string_page(u8 x,u8 p,u8 *s,u8 f,u8 o,u8 sp) { + + while(*(s)) { + if(x==DISPLAY_DIMX) { + p+=1; + x=o; + } + display_font_page(x,p,(u8 *)default_font+(*(s)<<3),f); + x+=sp; + s++; + } +} + +/* + * global variables + */ + +const char announce[]="betty - live from flash at 0x80000000! ;)\r\n"; +const char d1_txt[]="betty"; +const char d2_txt[]="- alphablend -"; + /* * main function */ int main() { - char announce[]="betty - live from flash at 0x80000000! ;)\r\n"; t_button button; u8 contrast; @@ -54,7 +74,7 @@ int main() { /* pasue again */ /* announce */ - uart0_send_string(announce); + uart0_send_string((char *)announce); while(1) { @@ -90,47 +110,31 @@ int main() { display_fill_screen(DISPLAY_FILL_B); break; case BUTTON_1: - display_draw_rectangle(20,20,40,40, - DISPLAY_FILL_B, - 0xff); + display_rectangle_page(4,2,60,5,DISPLAY_FILL_B,0xff); break; case BUTTON_2: - display_draw_rectangle(50,50,40,40, - DISPLAY_FILL_LG, - 0x7f); + display_rectangle_page(40,5,50,5,DISPLAY_FILL_LG,0x7f); break; case BUTTON_3: - display_draw_font(70,70, - (u8 *)default_font+(0x33<<3), - DISPLAY_FILL_LG, - 0xff); break; case BUTTON_4: - display_font_page(23,19,(u8 *)default_font+(0x34<<3),DISPLAY_FILL_B); + display_font_page(42,18,(u8 *)default_font+(0x34<<3),DISPLAY_FILL_B); break; case BUTTON_5: - display_font_page(10,19,(u8 *)default_font+(0x35<<3),DISPLAY_FILL_DG); + display_font_page(50,18,(u8 *)default_font+(0x35<<3),DISPLAY_FILL_DG); break; case BUTTON_6: - display_font_page(2,19,(u8 *)default_font+(0x36<<3),DISPLAY_FILL_LG); + display_font_page(58,18,(u8 *)default_font+(0x36<<3),DISPLAY_FILL_W); break; case BUTTON_7: - display_draw_rectangle(2,2,4,4, - DISPLAY_FILL_B, - 0xff); break; case BUTTON_8: - display_draw_rectangle(8,8,4,4, - DISPLAY_FILL_DG, - 0xff); break; case BUTTON_BETTY: - display_rectangle_page(80,15,16,2,DISPLAY_FILL_B,0x7f); - uart0_send_byte('b'); + display_string_page(50,13,(u8 *)d1_txt,DISPLAY_FILL_B,0,8); break; case BUTTON_EXIT: - display_rectangle_page(90,16,16,2,DISPLAY_FILL_LG,0x7f); - uart0_send_byte('e'); + display_string_page(10,8,(u8 *)d2_txt,DISPLAY_FILL_B,0,8); break; default: display_clear_screen(); diff --git a/betty/display.c b/betty/display.c index bb74241..46e8480 100644 --- a/betty/display.c +++ b/betty/display.c @@ -166,7 +166,7 @@ void display_rectangle_page(u8 x,u8 p,u8 w,u8 h,u8 fill,u8 alpha) { row=DISPLAY_DATA; // aligne dummy read for(row=0;row<8;row++) { b=display_m2i(buf,row); - c=(b*(255-alpha)+fill*255)>>8; + c=(b*(255-alpha)+fill*alpha)>>8; buf[0]&=~(1<