Subversion Repositories Kolibri OS

Rev

Rev 4051 | Rev 4215 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1742 mario79 1
;
2
; END
3443 leency 3
; KolibriOS Team 2005-2013
1742 mario79 4
;
4051 heavyiron 5
;  note that 'mov al,xx' is shorter than 'mov eax,xx'
6
;           and if we know that high 24 bits of eax are zero, we can use 1st form
7
;           the same about ebx,ecx,edx
1742 mario79 8
 
4213 heavyiron 9
use32        ; включить 32-битный режим ассемблера
10
org 0x0      ; адресация с нуля
1742 mario79 11
 
4213 heavyiron 12
db 'MENUET01'    ; 8-байтный идентификатор MenuetOS
13
dd 0x01          ; версия заголовка (всегда 1)
14
dd START         ; адрес первой команды
15
dd IM_END        ; размер программы
16
dd I_END         ; количество памяти
17
dd stacktop      ; адрес вершины стека
18
dd 0x0           ; адрес буфера для параметров
19
dd cur_dir_path
1742 mario79 20
 
4213 heavyiron 21
include 'lang.inc'
22
include '../../../macros.inc'
23
include '../../../proc32.inc'
24
include '../../../dll.inc'
25
include '../../../develop/libraries/box_lib/load_lib.mac'
26
include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
1742 mario79 27
 
4213 heavyiron 28
        @use_library
1742 mario79 29
 
4213 heavyiron 30
align 4
31
START:
1742 mario79 32
 
4213 heavyiron 33
load_libraries l_libs_start,end_l_libs
34
        inc     eax
35
        test    eax,eax
36
        jz      close
1742 mario79 37
 
4213 heavyiron 38
push    dword check1
39
call    [init_checkbox2]
1742 mario79 40
 
4213 heavyiron 41
stdcall dll.Init,[init_lib]
42
 
43
invoke  ini_get_int,ini_file,asettings,aautosave,0
44
        mov   [autosave],eax
45
        cmp   eax,1
46
        jne   @f
47
        bts   dword [check1.flags],1
48
@@:
49
        mcall   40,0x00000027
50
redraw:
51
    call draw_window
1742 mario79 52
still:
4051 heavyiron 53
    mov  al,10
54
    mcall                                    ;wait here for event
1742 mario79 55
    dec  eax
4213 heavyiron 56
    jz   redraw
1742 mario79 57
    dec  eax
4213 heavyiron 58
    jz   key
59
    dec  eax
60
    jz   button
4044 heavyiron 61
 
4213 heavyiron 62
    push dword check1
63
    call [check_box_mouse2]
64
    bt   dword [check1.flags],1
65
    jnc  @f
66
    mov  [autosave],1
67
    jmp  still
68
@@:
69
    mov  [autosave],0
70
    jmp  still
71
 
72
key:
4051 heavyiron 73
    mov  al,2
74
    mcall                                    ;eax=2 - get key code
1742 mario79 75
    mov  al,ah
76
     cmp  al,13
77
     jz   restart
78
     cmp  al,19
4213 heavyiron 79
     jz   checkbox
1742 mario79 80
     cmp  al,27
4213 heavyiron 81
     jz   close
1742 mario79 82
     cmp  al,180
83
     jz   restart_kernel
84
     cmp  al,181
85
     jz   power_off
86
     jmp  still
87
 
4044 heavyiron 88
button:
4213 heavyiron 89
    mcall 17                                 ;eax=17 - get pressed button id
1742 mario79 90
    xchg al,ah
91
    dec  eax
4213 heavyiron 92
    jz   close
1742 mario79 93
    dec  eax
94
    jz   restart_kernel
95
    dec  eax
96
    jz   restart
97
    dec  eax
4213 heavyiron 98
    jnz  checkbox
4044 heavyiron 99
 
2676 leency 100
power_off:
101
    push 2
102
    jmp  mcall_and_close
4213 heavyiron 103
 
2676 leency 104
restart:
1742 mario79 105
    push 3
106
    jmp  mcall_and_close
4213 heavyiron 107
 
4044 heavyiron 108
restart_kernel:
1742 mario79 109
    push 4
4213 heavyiron 110
 
1742 mario79 111
mcall_and_close:
4213 heavyiron 112
    invoke  ini_set_int,ini_file,asettings,aautosave,[autosave]
113
    cmp  [autosave],1
114
    jne   no_save
115
    mcall 70,rdsave
116
    test  eax,eax
117
    js    no_save
118
    mov   ecx,eax
119
    mcall 18,21
120
    mov   ecx,eax
121
@@:
122
    push ecx
123
    mcall 23,50
124
    dec   eax
125
    jnz   no_red
126
    call draw_window
127
no_red:
128
    pop   ecx
129
    mcall 9,proc_info
130
    cmp   [proc_info+50],9
131
    je    no_save
132
    jmp   @b
133
no_save:
1742 mario79 134
    pop  ecx
4213 heavyiron 135
    mcall 18,9
1742 mario79 136
 
4213 heavyiron 137
close:
138
    mcall -1
4044 heavyiron 139
 
4213 heavyiron 140
checkbox:
141
    btc   dword [check1.flags],1
142
    jc    .1
143
    mov   [autosave],1
144
    jmp   .draw
145
.1:
146
    mov   [autosave],0
147
.draw:
148
    push  dword check1
149
    call  [check_box_draw2]
150
    jmp    still
151
 
152
draw_window:
153
    mov   al,12
154
    mcall ,1
1742 mario79 155
 
4213 heavyiron 156
    mcall 14                                 ;eax=14 - get screen max x & max y
157
    movzx ecx,ax
158
    shr  eax,17
159
    shl  eax,16
160
    lea  ebx,[eax-110 shl 16+222]
161
    shr  ecx,1
162
    shl  ecx,16
163
    lea  ecx,[ecx-70 shl 16+117]
164
 
165
    xor eax,eax
166
    mcall  , , ,0x019098b0,0x01000000        ;define and draw window
167
 
168
    mov   al,13
169
    mcall   ,<0,223> ,<0,118>
170
    mcall   ,<1,221>,<1,116>,0xffffff
171
    mcall   ,<2,220>,<2,115>,0xe4dfe1
172
 
173
    mov    al,8
174
    mcall   ,<16,90> ,<20,27>,4,0x990022     ;eax=8 - draw buttons
175
    mcall   ,<113,90>,       ,2,0xaa7700
176
    mcall   ,        ,<54,27>,1,0x777777
177
    mcall   ,<16,90> ,       ,3,0x007700
178
 
179
    push  dword check1
180
    call  [check_box_draw2]
181
 
182
    mcall 4,<27,24> ,0x90ffffff,label2        ;eax=4 - write text
183
    mcall  ,<23,58> ,          ,label3
184
    mcall  ,<47,37> ,0x90ffffff,label5
185
    mcall  ,<44,71> ,          ,label6
186
 
187
    mov   al,12
188
    mcall   ,2
189
    ret
190
 
1742 mario79 191
data
4044 heavyiron 192
include 'data.inc'
1742 mario79 193
 
4213 heavyiron 194
;---------------------------------------------------------------------
195
IM_END:
196
;---------------------------------------------------------------------
197
align 4
1742 mario79 198
 
4213 heavyiron 199
proc_info  rb 1024
200
 
201
autosave rd 1
202
;---------------------------------------------------------------------
203
cur_dir_path:
204
        rb 4096
205
;---------------------------------------------------------------------
206
library_path:
207
        rb 4096
208
;---------------------------------------------------------------------
209
align 32
210
        rb 4096
211
stacktop:
212
I_END:  ; метка конца программы