Subversion Repositories Kolibri OS

Rev

Rev 1143 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1143 Rev 1144
1
; <--- description --->
1
; <--- description --->
2
; compiler:     FASM 1.67
2
; compiler:     FASM 1.67
3
; name:         Basic window example for KolibriOS
3
; name:         Basic window example for KolibriOS
4
; version:      1.02
4
; version:      1.02
5
; last update:  1/03/2007
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
;modified by: Heavyiron
8
;modified by: Heavyiron
9
 
9
 
10
; <--- include all MeOS stuff --->
10
; <--- include all MeOS stuff --->
11
include "lang.inc"
11
include "lang.inc"
12
include "..\..\..\..\macros.inc"
12
include "..\..\..\..\macros.inc"
13
 
13
 
14
 
14
 
15
; <--- start of MenuetOS application --->
15
; <--- start of MenuetOS application --->
16
MEOS_APP_START
16
MEOS_APP_START
17
 
17
 
18
 
18
 
19
; <--- start of code --->
19
; <--- start of code --->
20
CODE
20
CODE
21
 
21
 
22
   mov  eax,48                      ; get system colors
22
   mov  eax,48                      ; get system colors
23
   mov  ebx,3
23
   mov  ebx,3
24
   mov  ecx,sc
24
   mov  ecx,sc
25
   mov  edx,sizeof.system_colors
25
   mov  edx,sizeof.system_colors
26
   mcall
26
   mcall
27
 
27
 
28
  redraw:                                ; redraw event handler
28
  redraw:                                ; redraw event handler
29
   call    draw_window            ; at first create and draw the window
29
   call    draw_window            ; at first create and draw the window
30
 
-
 
31
    mcall   9, procinfo, -1
-
 
32
 
30
 
33
  wait_event:                      ; main cycle
31
  wait_event:                      ; main cycle
34
    mov     eax, 10
32
    mov     eax, 10
35
    mcall
33
    mcall
36
 
34
 
37
    dec   eax                    ;   if event = 1
35
    dec   eax                    ;   if event = 1
38
    jz      redraw               ;   jump to redraw handler
36
    jz      redraw               ;   jump to redraw handler
39
    dec   eax                    ;   else if event = 2
37
    dec   eax                    ;   else if event = 2
40
    jz      key                    ;   jump to key handler
38
    jz      key                    ;   jump to key handler
41
 
39
 
42
 
40
 
43
  button:                         ; button event handler
41
  button:                         ; button event handler
44
    mov     al, 17               ;   get button identifier
42
    mov     al, 17               ;   get button identifier
45
    mcall
43
    mcall
46
 
44
 
47
    cmp     ah, 1
45
    cmp     ah, 1
48
    jne     wait_event        ;   return if button id != 1
46
    jne     wait_event        ;   return if button id != 1
49
 
47
 
50
    or      eax, -1               ;   exit application
48
    or      eax, -1               ;   exit application
51
    mcall
49
    mcall
52
 
50
 
53
  key:                              ; key event handler
51
  key:                              ; key event handler
54
    mov     al, 2                 ;   get key code
52
    mov     al, 2                 ;   get key code
55
    mcall
53
    mcall
56
 
54
 
57
    jmp     wait_event
55
    jmp     wait_event
58
 
56
 
59
  draw_window:
57
  draw_window:
60
    mov     eax, 12                ; start drawing
58
    mov     eax, 12                ; start drawing
61
    mov     ebx, 1
59
    mov     ebx, 1
62
    mcall
60
    mcall
63
 
61
 
64
    xor       eax, eax                      ; create and draw the window
62
    xor       eax, eax                      ; create and draw the window
65
    mov     ebx, 100*65536+200 ; (window_cx)*65536+(window_sx)
63
    mov     ebx, 100*65536+200 ; (window_cx)*65536+(window_sx)
66
    mov     ecx, 100*65536+100  ; (window_cy)*65536+(window_sy)
64
    mov     ecx, 100*65536+100  ; (window_cy)*65536+(window_sy)
67
    mov     edx, [sc.work]              ; work area color 
65
    mov     edx, [sc.work]              ; work area color 
68
    or         edx, 0x33000000        ; & window type 3
66
    or         edx, 0x33000000        ; & window type 3
69
    mov     edi, title                    ; window title
67
    mov     edi, title                    ; window title
70
    int        0x40
68
    int        0x40
71
 
69
 
72
    mov     eax, 12                ; finish drawing
70
    mov     eax, 12                ; finish drawing
73
    mov     ebx, 2
71
    mov     ebx, 2
74
    mcall
72
    mcall
75
 
73
 
76
  ret
74
  ret
77
 
75
 
78
; <--- initialised data --->
76
; <--- initialised data --->
79
DATA
77
DATA
80
 
78
 
81
if lang eq ru
79
if lang eq ru
82
title db '˜ ¡«®­ ¯à®£à ¬¬ë',0
80
title db '˜ ¡«®­ ¯à®£à ¬¬ë',0
83
else if lang eq fr
81
else if lang eq fr
84
title db 'La programme poncive',0
82
title db 'La programme poncive',0
85
else
83
else
86
title db 'Template program',0
84
title db 'Template program',0
87
end if
85
end if
88
 
86
 
89
; <--- uninitialised data --->
87
; <--- uninitialised data --->
90
UDATA
88
UDATA
91
sc   system_colors
89
sc   system_colors
92
 
-
 
93
procinfo    rb  1024
-
 
94
 
90
 
95
MEOS_APP_END
91
MEOS_APP_END
96
; <--- end of MenuetOS application --->
92
; <--- end of MenuetOS application --->