Rev 5098 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5098 | Rev 5132 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include |
1 | #include |
Line 2... | Line 2... | ||
2 | 2 | ||
Line 3... | Line 3... | ||
3 | #define B_SZ 10 |
3 | #define B_SZ 10 |
Line 4... | Line 4... | ||
4 | 4 | ||
5 | static char * Title="BinClock"; |
5 | static char * Title="BinClock"; |
6 | 6 | ||
7 | static void draw_small_box(int x,int y,int is_on) |
7 | static void draw_small_box(int x,int y,int is_on) |
Line 8... | Line 8... | ||
8 | { |
8 | { |
9 | __menuet__bar(x,y,B_SZ,B_SZ,is_on ? 0xFF0000 : 0x103000); |
9 | draw_bar(x,y,B_SZ,B_SZ,is_on ? 0xFF0000 : 0x103000); |
10 | } |
10 | } |
Line 18... | Line 18... | ||
18 | for(i=0;i<4;i++) |
18 | for(i=0;i<4;i++) |
19 | { |
19 | { |
20 | j=(B_SZ+2)*i; |
20 | j=(B_SZ+2)*i; |
21 | draw_small_box(x,y+((B_SZ+2)*i),num & (1<<(3-i)) ? 1 : 0); |
21 | draw_small_box(x,y+((B_SZ+2)*i),num & (1<<(3-i)) ? 1 : 0); |
22 | } |
22 | } |
23 | __menuet__bar(x,y+((B_SZ+2)*4),B_SZ,B_SZ,0x800000); |
23 | draw_bar(x,y+((B_SZ+2)*4),B_SZ,B_SZ,0x800000); |
24 | __menuet__write_text(x+2,y+((B_SZ+2)*4)+3,0xFFFFFF,buf,1); |
24 | draw_text_sys(buf,x+2,y+((B_SZ+2)*4)+3,1,0xFFFFFF); |
25 | } |
25 | } |
Line 26... | Line 26... | ||
26 | 26 | ||
27 | static void draw_bcd_num(int x,int y,int num) |
27 | static void draw_bcd_num(int x,int y,int num) |
28 | { |
28 | { |
Line 33... | Line 33... | ||
33 | draw_box_group(x+B_SZ+2,y,v2); |
33 | draw_box_group(x+B_SZ+2,y,v2); |
34 | } |
34 | } |
Line 35... | Line 35... | ||
35 | 35 | ||
36 | static void draw_hms(int x,int y) |
36 | static void draw_hms(int x,int y) |
37 | { |
37 | { |
38 | __u32 t; |
38 | unsigned t; |
39 | int h,m,s; |
39 | int h,m,s; |
40 | t=__menuet__getsystemclock(); |
40 | __asm__ __volatile__("int $0x40" : "=a"(t) : "a"(3)); |
41 | s=(t & 0x00FF0000)>>16; |
41 | s=(t & 0x00FF0000)>>16; |
42 | m=(t & 0x0000FF00)>>8; |
42 | m=(t & 0x0000FF00)>>8; |
43 | h=(t & 0x000000FF); |
43 | h=(t & 0x000000FF); |
44 | draw_bcd_num(x,y,h); |
44 | draw_bcd_num(x,y,h); |
Line 53... | Line 53... | ||
53 | draw_hms(22,28); |
53 | draw_hms(22,28); |
54 | } |
54 | } |
Line 55... | Line 55... | ||
55 | 55 | ||
56 | static void paint(void) |
56 | static void paint(void) |
57 | { |
57 | { |
58 | __menuet__window_redraw(1); |
58 | BeginDraw(); |
59 | __menuet__define_window(100,100,40+((B_SZ+2)*6)+4,30+((B_SZ+2)*4)+16,0x03000080,0x800000FF,0x000080); |
- | |
60 | __menuet__write_text(3,3,0xFFFFFF,Title,strlen(Title)); |
59 | DrawWindow(100,100,40+((B_SZ+2)*6)+4,30+((B_SZ+2)*4)+16,Title,0x80,0x13); |
61 | __menuet__bar(20,26,((B_SZ+2)*6)+4+2,4+((B_SZ+1)*4)+2,0); |
60 | draw_bar(20,26,((B_SZ+2)*6)+4+2,4+((B_SZ+1)*4)+2,0); |
62 | draw_h(); |
61 | draw_h(); |
63 | __menuet__window_redraw(2); |
62 | EndDraw(); |
Line 64... | Line 63... | ||
64 | } |
63 | } |
65 | 64 | ||
66 | void main(void) |
65 | int main(void) |
67 | { |
66 | { |
68 | int i; |
67 | int i; |
69 | paint(); |
68 | paint(); |
70 | for(;;) |
- | |
71 | { |
69 | for(;;) |
72 | __menuet__delay100(20); |
70 | { |
73 | i=__menuet__check_for_event(); |
71 | i=wait_for_event(20); |
74 | draw_h(); |
72 | draw_h(); |
75 | switch(i) |
73 | switch(i) |
76 | { |
74 | { |
77 | case 1: |
75 | case 1: |
78 | paint(); |
76 | paint(); |
79 | continue; |
77 | continue; |
80 | case 2: |
78 | case 2: |
81 | __menuet__getkey(); |
79 | get_key(); |
82 | continue; |
80 | continue; |
83 | case 3: |
81 | case 3: |
84 | if(__menuet__get_button_id()==1) __menuet__sys_exit(); |
82 | if(get_os_button()==1) return 0; |
85 | continue; |
83 | continue; |
86 | } |
84 | } |
Line 87... | Line 85... | ||
87 | } |
85 | } |