Rev 109 | Rev 485 | Go to most recent revision | Show entire file | Ignore 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 ---> |
|
- | 20 | CODE |
|
- | 21 | ||
- | 22 | mov eax,48 ; get system colors |
|
- | 23 | mov ebx,3 |
|
- | 24 | mov ecx,sc |
|
- | 25 | mov edx,sizeof.system_colors |
|
- | 26 | int 0x40 |
|
19 | ; <--- start of code ---> |
27 | |
Line 20... | Line 28... | ||
20 | CODE |
28 | redraw: ; redraw event handler |
21 | call draw_window ; at first create and draw the window |
29 | call draw_window ; at first create and draw the window |
22 | 30 | ||
Line 23... | Line 31... | ||
23 | wait_event: ; main cycle |
31 | wait_event: ; main cycle |
24 | mov eax, 10 |
32 | mov eax, 10 |
25 | int 0x40 |
33 | int 0x40 |
26 | 34 | ||
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 | - | ||
34 | jmp wait_event ; else return to the start of main cycle |
- | |
35 | - | ||
Line 36... | Line 35... | ||
36 | 35 | dec eax ; if event = 1 |
|
37 | redraw: ; redraw event handler |
36 | jz redraw ; jump to redraw handler |
38 | call draw_window |
37 | dec eax ; else if event = 2 |
Line 39... | Line 38... | ||
39 | jmp wait_event |
38 | jz key ; jump to key handler |
40 | - | ||
- | 39 | ||
Line 41... | Line -... | ||
41 | - | ||
42 | key: ; key event handler |
40 | |
43 | mov eax, 2 ; get key code |
41 | button: ; button event handler |
Line 44... | Line -... | ||
44 | int 0x40 |
- | |
45 | 42 | mov al, 17 ; get button identifier |
|
46 | jmp wait_event |
- | |
47 | 43 | int 0x40 |
|
48 | 44 | ||
Line -... | Line 45... | ||
- | 45 | cmp ah, 1 |
|
Line 49... | Line 46... | ||
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 |
52 | 49 | int 0x40 |
|
Line 53... | Line 50... | ||
53 | cmp ah, 1 |
50 | |
54 | jne wait_event ; return if button id != 1 |
51 | key: ; key event handler |
55 | 52 | mov al, 2 ; get key code |
|
56 | or eax, -1 ; exit application |
- | |
57 | int 0x40 |
- | |
58 | - | ||
59 | - | ||
60 | draw_window: |
- | |
61 | mov eax, 12 ; start drawing |
53 | int 0x40 |
62 | mov ebx, 1 |
- | |
63 | int 0x40 |
54 | |
64 | 55 | jmp wait_event |
|
65 | mov eax, 0 ; create and draw the window |
- | |
66 | mov ebx, 100*65536+300 ; (window_cx)*65536+(window_sx) |
56 | |
Line 67... | Line 57... | ||
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 |
69 | ; mov esi, 0 ; grab color (not used) |
59 | mov ebx, 1 |
Line 70... | Line 60... | ||
70 | ; mov edi, 0 ; frame color (not used) |
60 | int 0x40 |
Line 71... | Line -... | ||
71 | int 0x40 |
- | |
72 | - | ||
73 | mov eax, 4 ; window header |
61 | |
74 | mov ebx, 8*65536+8 ; coordinates |
62 | xor eax, eax ; create and draw the window |
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 |
- | |
79 | - | ||
Line -... | Line 63... | ||
- | 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 |
|
- | 69 | ||
Line 80... | Line 70... | ||
80 | mov eax, 12 ; finish drawing |
70 | mov eax, 12 ; finish drawing |
81 | mov ebx, 2 |
71 | mov ebx, 2 |
82 | int 0x40 |
- | |
- | 72 | int 0x40 |
|
Line 83... | Line 73... | ||
83 | 73 | ||
84 | ret |
74 | ret |
85 | 75 |