]> hackdaworld.org Git - my-code/arm.git/commitdiff
alpha blending
authorhackbard <hackbard@staubsauger.localdomain>
Sun, 16 Sep 2007 14:19:55 +0000 (16:19 +0200)
committerhackbard <hackbard@staubsauger.localdomain>
Sun, 16 Sep 2007 14:19:55 +0000 (16:19 +0200)
betty/Makefile
betty/betty.c
betty/display.c
betty/functions.c
betty/functions.h

index 28184c3ff2d3264c72f87247fecb90b27161f3e5..4d2a1aa44450803513cd65d6596c7ff0a146d1bd 100644 (file)
@@ -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
index 8d7ce84be5c46cf6c29b59330b697ba7b88ce51e..093232bcaeb1048cbaf3ab63b9ec61c2dc1f50d7 100644 (file)
 
 #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();
index bb742415ad3a22f81a9c44566e3da4bd6b08efca..46e8480a1e881cb698c67af4f21967fa04b539be 100644 (file)
@@ -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<<row);
                                buf[1]&=~(1<<row);
                                if(c&2)
index cc03941f26a9dacb68581b63f061a50b1d6f3960..732e76fe476c4aa4884797b75acb649e3c1f59c0 100644 (file)
@@ -52,11 +52,30 @@ int strncpy(char *d,char *s,int n) {
        return 0;
 }
 
-int mset(u8 *s,u8 v,int n) {
+int mset(u8 *d,u8 v,int n) {
 
        while(n)
-               s[--n]=v;
+               d[--n]=v;
 
        return 0;
 }
 
+int mcpy(u8 *d,u8 *s,int n) {
+
+       while(n)
+               *d++=*s++;
+
+       return n;
+}
+
+int counttok(u8 *s,u8 delim) {
+
+       int n;
+
+       n=0;
+       while(*s++!=delim)
+               n++;
+       
+       return n;
+}
+
index db5529671a62452378103f23edacc214e1f72333..aa9c11a54a4c8ed1ab9bc6556328a70e124dab96 100644 (file)
@@ -19,5 +19,7 @@ int strlen(char *string);
 int strncmp(char *a,char *b,int n);
 int strncpy(char *d,char *s,int n);
 int mset(u8 *s,u8 v,int n);
+int mcpy(u8 *d,u8 *s,int n);
+int counttok(u8 *s,u8 delim);
 
 #endif