Subversion Repositories Kolibri OS

Rev

Rev 4215 | Rev 4266 | 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
4215 heavyiron 45
        dec   eax
46
        jnz   @f
4213 heavyiron 47
        bts   dword [check1.flags],1
48
@@:
4215 heavyiron 49
        mcall   40,0x80000027
4213 heavyiron 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
4215 heavyiron 77
     je   restart
1742 mario79 78
     cmp  al,19
4215 heavyiron 79
     je   checkbox
1742 mario79 80
     cmp  al,180
4215 heavyiron 81
     je   restart_kernel
1742 mario79 82
     cmp  al,181
4215 heavyiron 83
     je   power_off
84
     cmp  al,27
85
     jne   still
1742 mario79 86
 
4215 heavyiron 87
close:
88
    mcall -1
89
 
4044 heavyiron 90
button:
4213 heavyiron 91
    mcall 17                                 ;eax=17 - get pressed button id
1742 mario79 92
    xchg al,ah
93
    dec  eax
4213 heavyiron 94
    jz   close
1742 mario79 95
    dec  eax
96
    jz   restart_kernel
97
    dec  eax
98
    jz   restart
99
    dec  eax
4213 heavyiron 100
    jnz  checkbox
4044 heavyiron 101
 
2676 leency 102
power_off:
103
    push 2
104
    jmp  mcall_and_close
4213 heavyiron 105
 
2676 leency 106
restart:
1742 mario79 107
    push 3
108
    jmp  mcall_and_close
4213 heavyiron 109
 
4044 heavyiron 110
restart_kernel:
1742 mario79 111
    push 4
4213 heavyiron 112
 
1742 mario79 113
mcall_and_close:
4213 heavyiron 114
    invoke  ini_set_int,ini_file,asettings,aautosave,[autosave]
115
    cmp  [autosave],1
116
    jne   no_save
117
    mcall 70,rdsave
118
    test  eax,eax
119
    js    no_save
120
    mov   ecx,eax
121
    mcall 18,21
122
    mov   ecx,eax
123
@@:
124
    push ecx
4215 heavyiron 125
    mcall 23,100
4213 heavyiron 126
    dec   eax
127
    jnz   no_red
128
    call draw_window
129
no_red:
130
    pop   ecx
131
    mcall 9,proc_info
132
    cmp   [proc_info+50],9
133
    je    no_save
134
    jmp   @b
135
no_save:
1742 mario79 136
    pop  ecx
4213 heavyiron 137
    mcall 18,9
4250 heavyiron 138
ret
1742 mario79 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
4215 heavyiron 154
    mcall   ,1
1742 mario79 155
 
4215 heavyiron 156
    mov   al,14
157
    mcall                                    ;eax=14 - get screen max x & max y
4213 heavyiron 158
    movzx ecx,ax
4215 heavyiron 159
    shr   eax,17
160
    shl   eax,16
161
    lea   ebx,[eax-110 shl 16+222]
162
    shr   ecx,1
163
    shl   ecx,16
164
    lea   ecx,[ecx-70 shl 16+117]
4213 heavyiron 165
 
4215 heavyiron 166
    xor   eax,eax
4213 heavyiron 167
    mcall  , , ,0x019098b0,0x01000000        ;define and draw window
168
 
169
    mov   al,13
170
    mcall   ,<0,223> ,<0,118>
171
    mcall   ,<1,221>,<1,116>,0xffffff
172
    mcall   ,<2,220>,<2,115>,0xe4dfe1
173
 
4215 heavyiron 174
    mov   al,8
4213 heavyiron 175
    mcall   ,<16,90> ,<20,27>,4,0x990022     ;eax=8 - draw buttons
176
    mcall   ,<113,90>,       ,2,0xaa7700
177
    mcall   ,        ,<54,27>,1,0x777777
178
    mcall   ,<16,90> ,       ,3,0x007700
179
 
4215 heavyiron 180
    mov   al,4
181
    mcall   ,<27,24> ,0x90ffffff,label2        ;eax=4 - write text
182
    mcall   ,<23,58> ,          ,label3
183
    mcall   ,<47,37> ,          ,label5
184
    mcall   ,<41,71> ,          ,label6
185
 
4213 heavyiron 186
    push  dword check1
187
    call  [check_box_draw2]
188
 
189
    mov   al,12
190
    mcall   ,2
191
    ret
4215 heavyiron 192
;---------------------------------------------------------------------
193
;data
4044 heavyiron 194
include 'data.inc'
1742 mario79 195
 
4213 heavyiron 196
;---------------------------------------------------------------------
197
IM_END:
198
;---------------------------------------------------------------------
199
align 4
1742 mario79 200
 
4213 heavyiron 201
proc_info  rb 1024
202
 
203
autosave rd 1
204
;---------------------------------------------------------------------
205
cur_dir_path:
206
        rb 4096
207
;---------------------------------------------------------------------
208
library_path:
209
        rb 4096
210
;---------------------------------------------------------------------
211
align 32
212
        rb 4096
213
stacktop:
214
I_END:  ; метка конца программы