Rev 109 | Rev 485 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 109 | Rev 383 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ; <--- description ---> |
1 | ; <--- description ---> |
2 | ; compiler: FASM 1.50 |
2 | ; compiler: FASM 1.67 |
3 | ; name: Basic window example for MenuetOS |
3 | ; name: Basic window example for KolibriOS |
4 | ; version: 1.01 |
4 | ; version: 1.02 |
5 | ; last update: 25/08/2004 |
5 | ; last update: 1/03/2007 |
6 | ; written by: Ivan Poddubny |
6 | ; written by: Ivan Poddubny |
7 | ; e-mail: ivan-yar@bk.ru |
7 | ; e-mail: ivan-yar@bk.ru |
8 | - | ||
- | 8 | ;modified by: Heavyiron |
|
Line 9... | Line 9... | ||
9 | 9 | ||
10 | ; <--- include all MeOS stuff ---> |
10 | ; <--- include all MeOS stuff ---> |
11 | include "lang.inc" |
11 | include "lang.inc" |
Line 16... | Line 16... | ||
16 | MEOS_APP_START |
16 | MEOS_APP_START |
Line 17... | Line 17... | ||
17 | 17 | ||
18 | 18 | ||
19 | ; <--- start of code ---> |
- | |
Line 20... | Line 19... | ||
20 | CODE |
19 | ; <--- start of code ---> |
- | 20 | CODE |
|
21 | call draw_window ; at first create and draw the window |
21 | |
- | 22 | mov eax,48 ; get system colors |
|
22 | 23 | mov ebx,3 |
|
Line 23... | Line -... | ||
23 | wait_event: ; main cycle |
- | |
24 | mov eax, 10 |
- | |
25 | int 0x40 |
- | |
26 | - | ||
27 | cmp eax, 1 ; if event == 1 |
- | |
28 | je redraw ; jump to redraw handler |
- | |
29 | cmp eax, 2 ; else if event == 2 |
- | |
30 | je key ; jump to key handler |
- | |
31 | cmp eax, 3 ; else if event == 3 |
- | |
32 | je button ; jump to button handler |
- | |
33 | 24 | mov ecx,sc |
|
34 | jmp wait_event ; else return to the start of main cycle |
25 | mov edx,sizeof.system_colors |
35 | - | ||
36 | - | ||
Line 37... | Line 26... | ||
37 | redraw: ; redraw event handler |
26 | int 0x40 |
38 | call draw_window |
27 | |
39 | jmp wait_event |
28 | redraw: ; redraw event handler |
Line 40... | Line 29... | ||
40 | 29 | call draw_window ; at first create and draw the window |
|
- | 30 | ||
- | 31 | wait_event: ; main cycle |
|
- | 32 | mov eax, 10 |
|
Line 41... | Line 33... | ||
41 | 33 | int 0x40 |
|
42 | key: ; key event handler |
34 | |
43 | mov eax, 2 ; get key code |
35 | dec eax ; if event = 1 |
Line 44... | Line 36... | ||
44 | int 0x40 |
36 | jz redraw ; jump to redraw handler |
45 | 37 | dec eax ; else if event = 2 |
|
Line 46... | Line 38... | ||
46 | jmp wait_event |
38 | jz key ; jump to key handler |
47 | 39 | ||
Line -... | Line 40... | ||
- | 40 | ||
- | 41 | button: ; button event handler |
|
- | 42 | mov al, 17 ; get button identifier |
|
- | 43 | int 0x40 |
|
- | 44 | ||
Line 48... | Line 45... | ||
48 | 45 | cmp ah, 1 |
|
49 | button: ; button event handler |
46 | jne wait_event ; return if button id != 1 |
50 | mov eax, 17 ; get button identifier |
47 | |
51 | int 0x40 |
48 | or eax, -1 ; exit application |
Line 52... | Line 49... | ||
52 | 49 | int 0x40 |
|
53 | cmp ah, 1 |
50 | |
54 | jne wait_event ; return if button id != 1 |
51 | key: ; key event handler |
55 | - | ||
56 | or eax, -1 ; exit application |
- | |
57 | int 0x40 |
- | |
58 | - | ||
59 | - | ||
60 | draw_window: |
52 | mov al, 2 ; get key code |
61 | mov eax, 12 ; start drawing |
- | |
62 | mov ebx, 1 |
53 | int 0x40 |
63 | int 0x40 |
54 | |
64 | - | ||
65 | mov eax, 0 ; create and draw the window |
55 | jmp wait_event |
Line 66... | Line 56... | ||
66 | mov ebx, 100*65536+300 ; (window_cx)*65536+(window_sx) |
56 | |
67 | mov ecx, 100*65536+200 ; (window_cy)*65536+(window_sy) |
57 | draw_window: |
68 | mov edx, 0x03ffffff ; work area color & window type 3 |
58 | mov eax, 12 ; start drawing |
Line 69... | Line 59... | ||
69 | ; mov esi, 0 ; grab color (not used) |
59 | mov ebx, 1 |
Line 70... | Line -... | ||
70 | ; mov edi, 0 ; frame color (not used) |
- | |
71 | int 0x40 |
- | |
72 | 60 | int 0x40 |
|
73 | mov eax, 4 ; window header |
61 | |
74 | mov ebx, 8*65536+8 ; coordinates |
- | |
75 | mov ecx, 0x10ffffff ; color & font N1 |
- | |
76 | mov edx, header ; address of text |
- | |
77 | mov esi, header.size ; length of text |
- | |
78 | int 0x40 |
- | |
Line -... | Line 62... | ||
- | 62 | xor eax, eax ; create and draw the window |
|
- | 63 | mov ebx, 100*65536+200 ; (window_cx)*65536+(window_sx) |
|
- | 64 | mov ecx, 100*65536+100 ; (window_cy)*65536+(window_sy) |
|
- | 65 | mov edx, [sc.work] ; work area color |
|
- | 66 | or edx, 0x33000000 ; & window type 3 |
|
- | 67 | mov edi, header ; window header |
|
- | 68 | int 0x40 |
|
Line 79... | Line 69... | ||
79 | 69 | ||
80 | mov eax, 12 ; finish drawing |
70 | mov eax, 12 ; finish drawing |
81 | mov ebx, 2 |
- | |
- | 71 | mov ebx, 2 |
|
Line 82... | Line 72... | ||
82 | int 0x40 |
72 | int 0x40 |
83 | 73 | ||
84 | ret |
74 | ret |