Rev 5132 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5132 | Rev 9952 | ||
---|---|---|---|
1 | #include |
1 | #include |
2 | 2 | ||
3 | #define B_SZ 10 |
3 | #define B_SZ 10 |
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) |
8 | { |
8 | { |
9 | draw_bar(x,y,B_SZ,B_SZ,is_on ? 0xFF0000 : 0x103000); |
9 | _ksys_draw_bar(x, y, B_SZ, B_SZ, is_on ? 0xFF0000 : 0x103000); |
10 | } |
10 | } |
11 | 11 | ||
12 | static void draw_box_group(int x,int y,int num) |
12 | static void draw_box_group(int x, int y, int num) |
13 | { |
13 | { |
14 | int i,j; |
14 | int i, j; |
15 | char buf[2]; |
15 | char buf[2]; |
16 | buf[0]=(num&(1+2+4+8))+'0'; |
16 | buf[0] = (num&(1+2+4+8))+'0'; |
17 | buf[1]='\0'; |
17 | buf[1] = '\0'; |
18 | for(i=0;i<4;i++) |
18 | for(i = 0; i < 4; i++) { |
19 | { |
- | |
20 | j=(B_SZ+2)*i; |
19 | j = (B_SZ+2)*i; |
21 | draw_small_box(x,y+((B_SZ+2)*i),num & (1<<(3-i)) ? 1 : 0); |
20 | draw_small_box(x,y+((B_SZ+2)*i),num & (1<<(3-i)) ? 1 : 0); |
22 | } |
21 | } |
23 | draw_bar(x,y+((B_SZ+2)*4),B_SZ,B_SZ,0x800000); |
22 | _ksys_draw_bar(x, y+((B_SZ+2)*4),B_SZ,B_SZ, 0x800000); |
24 | draw_text_sys(buf,x+2,y+((B_SZ+2)*4)+3,1,0xFFFFFF); |
23 | _ksys_draw_text(buf, x+2, y+((B_SZ+2)*4)+3, 1, 0xFFFFFF); |
25 | } |
24 | } |
26 | 25 | ||
27 | static void draw_bcd_num(int x,int y,int num) |
26 | static void draw_bcd_num(int x,int y,int num) |
28 | { |
27 | { |
29 | int v1,v2; |
28 | int v1, v2; |
30 | v1=(num>>4)&(1+2+4+8); |
29 | v1 = (num>>4)&(1+2+4+8); |
31 | v2=num & (1+2+4+8); |
30 | v2 = num&(1+2+4+8); |
32 | draw_box_group(x,y,v1); |
31 | draw_box_group(x, y, v1); |
33 | draw_box_group(x+B_SZ+2,y,v2); |
32 | draw_box_group(x+B_SZ+2, y ,v2); |
34 | } |
33 | } |
35 | 34 | ||
36 | static void draw_hms(int x,int y) |
35 | static void draw_hms(int x,int y) |
37 | { |
36 | { |
38 | unsigned t; |
37 | unsigned t; |
39 | int h,m,s; |
38 | int h, m, s; |
40 | __asm__ __volatile__("int $0x40" : "=a"(t) : "a"(3)); |
39 | __asm__ __volatile__("int $0x40" : "=a"(t) : "a"(3)); |
41 | s=(t & 0x00FF0000)>>16; |
40 | s = (t & 0x00FF0000)>>16; |
42 | m=(t & 0x0000FF00)>>8; |
41 | m = (t & 0x0000FF00)>>8; |
43 | h=(t & 0x000000FF); |
42 | h = (t & 0x000000FF); |
44 | draw_bcd_num(x,y,h); |
43 | draw_bcd_num(x,y,h); |
45 | x+=((B_SZ+2)<<1)+2; |
44 | x+=((B_SZ+2)<<1)+2; |
46 | draw_bcd_num(x,y,m); |
45 | draw_bcd_num(x,y,m); |
47 | x+=((B_SZ+2)<<1)+2; |
46 | x+=((B_SZ+2)<<1)+2; |
48 | draw_bcd_num(x,y,s); |
47 | draw_bcd_num(x,y,s); |
49 | } |
48 | } |
50 | 49 | ||
51 | static void draw_h(void) |
50 | static void draw_h(void) |
52 | { |
51 | { |
53 | draw_hms(22,28); |
52 | draw_hms(22, 28); |
54 | } |
53 | } |
55 | 54 | ||
56 | static void paint(void) |
55 | static void paint(void) |
57 | { |
56 | { |
58 | BeginDraw(); |
57 | _ksys_start_draw(); |
59 | DrawWindow(100,100,40+((B_SZ+2)*6)+4,30+((B_SZ+2)*4)+16,Title,0x80,0x13); |
58 | _ksys_create_window(100, 100, 40+((B_SZ+2)*6)+4,30+((B_SZ+2)*4)+16, title, 0x80, 0x13); |
60 | draw_bar(20,26,((B_SZ+2)*6)+4+2,4+((B_SZ+1)*4)+2,0); |
59 | _ksys_draw_bar(20, 26, ((B_SZ+2)*6)+4+2,4+((B_SZ+1)*4)+2, 0); |
61 | draw_h(); |
60 | draw_h(); |
62 | EndDraw(); |
61 | _ksys_end_draw(); |
63 | } |
62 | } |
64 | 63 | ||
65 | int main(void) |
64 | int main(void) |
66 | { |
65 | { |
67 | int i; |
66 | int i; |
68 | paint(); |
67 | paint(); |
- | 68 | ||
69 | for(;;) |
69 | for(;;) { |
70 | { |
- | |
71 | i=wait_for_event(20); |
70 | i = _ksys_wait_event_timeout(20); |
72 | draw_h(); |
71 | draw_h(); |
73 | switch(i) |
72 | switch(i) { |
74 | { |
- | |
75 | case 1: |
73 | case 1: |
76 | paint(); |
74 | paint(); |
77 | continue; |
75 | continue; |
78 | case 2: |
76 | case 2: |
79 | get_key(); |
77 | _ksys_get_key(); |
80 | continue; |
78 | continue; |
81 | case 3: |
79 | case 3: |
82 | if(get_os_button()==1) return 0; |
80 | if (_ksys_get_button() == 1) return 0; |
83 | continue; |
81 | continue; |
84 | } |
82 | } |
85 | } |
83 | } |
86 | }1)+2; |
84 | }1)+2; |
87 | ><1)+2; |
85 | ><1)+2; |
88 | >1)+2; |
86 | >1)+2; |
89 | ><1)+2; |
87 | ><1)+2; |
90 | >(3-i))><(3-i))>4;i++) |
88 | >(3-i))><(3-i))>> |
91 | > |
- |