Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1742 mario79 1
; END
8532 IgorA 2
; KolibriOS Team 2005-2021
5665 Pathoswith 3
 
9456 leency 4
use32         ; включить 32-битный режим ассемблера
5
org 0x0       ; адресация с нуля
1742 mario79 6
 
9456 leency 7
db 'MENUET01' ; 8-байтный идентификатор MenuetOS
8
dd 0x01       ; версия заголовка (всегда 1)
9
dd START      ; адрес первой команды
10
dd IM_END     ; размер программы
11
dd I_END      ; количество памяти
12
dd stacktop   ; адрес вершины стека
13
dd 0x0        ; адрес буфера для параметров
14
dd 0x0
1742 mario79 15
 
4213 heavyiron 16
include 'lang.inc'
17
include '../../../macros.inc'
18
include '../../../proc32.inc'
19
include '../../../dll.inc'
8532 IgorA 20
include '../../../KOSfuncs.inc'
21
include '../../../load_lib.mac'
6215 leency 22
include '../../../gui_patterns.inc'
9456 leency 23
include '../../../string.inc'
1742 mario79 24
 
6190 leency 25
@use_library
1742 mario79 26
 
4213 heavyiron 27
START:
9456 leency 28
    mcall SF_SYS_MISC, SSF_HEAP_INIT
29
    mcall SF_SYS_MISC, SSF_MEM_OPEN, checkbox_sharedname
30
    mov [checkbox_img], eax
1742 mario79 31
 
9456 leency 32
    load_libraries l_libs_start,end_l_libs
33
    inc   eax
34
    test  eax,eax
35
    jz    close
6190 leency 36
 
9456 leency 37
    stdcall dll.Init,[init_lib]
1742 mario79 38
 
9456 leency 39
    invoke ini_get_int,ini_file,asettings,aautosave,0
40
    mov   [autosave],eax
4213 heavyiron 41
redraw:
9456 leency 42
    call  draw_window
1742 mario79 43
still:
9456 leency 44
    mcall SF_WAIT_EVENT        ;wait here for event
45
    dec   eax
46
    jz    redraw
47
    dec   eax
48
    jz    key
49
    dec   eax
50
    jz    button
51
    jmp   still
4044 heavyiron 52
 
4213 heavyiron 53
key:
9456 leency 54
    mcall SF_GET_KEY        ;get key code
55
    mov   al,ah
1742 mario79 56
     cmp  al,13
4215 heavyiron 57
     je   restart
1742 mario79 58
     cmp  al,19
4215 heavyiron 59
     je   checkbox
1742 mario79 60
     cmp  al,180
4215 heavyiron 61
     je   restart_kernel
1742 mario79 62
     cmp  al,181
4215 heavyiron 63
     je   power_off
64
     cmp  al,27
9456 leency 65
     jne  still
1742 mario79 66
 
4215 heavyiron 67
close:
8532 IgorA 68
    mcall SF_TERMINATE_PROCESS
4215 heavyiron 69
 
4044 heavyiron 70
button:
9456 leency 71
    mcall SF_GET_BUTTON                     ;get pressed button id
72
    xchg  al,ah
73
    dec   eax
74
    jz    close
75
    dec   eax
76
    jz    restart_kernel
77
    dec   eax
78
    jz    restart
79
    dec   eax
80
    jnz   checkbox
4044 heavyiron 81
 
2676 leency 82
power_off:
9456 leency 83
    push  2
84
    jmp   mcall_and_close
4213 heavyiron 85
 
2676 leency 86
restart:
9456 leency 87
    push  3
88
    jmp   mcall_and_close
4213 heavyiron 89
 
4044 heavyiron 90
restart_kernel:
9456 leency 91
    push  4
4213 heavyiron 92
 
1742 mario79 93
mcall_and_close:
9456 leency 94
    invoke ini_set_int,ini_file,asettings,aautosave,[autosave]
95
    cmp   [autosave],1
4213 heavyiron 96
    jne   no_save
4284 heavyiron 97
 
9456 leency 98
    mcall SF_DRAW_TEXT,<55,108>,0x90FF990A,TEXT_SAVING
4284 heavyiron 99
 
8532 IgorA 100
    mcall SF_FILE,rdsave
4213 heavyiron 101
    test  eax,eax
9456 leency 102
    js    no_save
4213 heavyiron 103
    mov   ecx,eax
8532 IgorA 104
    mcall SF_SYSTEM,SSF_GET_THREAD_SLOT
4213 heavyiron 105
    mov   ecx,eax
106
@@:
107
    push ecx
8532 IgorA 108
    mcall SF_WAIT_EVENT_TIMEOUT,100
4213 heavyiron 109
    dec   eax
110
    jnz   no_red
9456 leency 111
    call  draw_window
4266 heavyiron 112
no_red:
4213 heavyiron 113
    pop   ecx
8532 IgorA 114
    mcall SF_THREAD_INFO,proc_info
4213 heavyiron 115
    cmp   [proc_info+50],9
9456 leency 116
    je    no_save
4213 heavyiron 117
    jmp   @b
118
no_save:
9456 leency 119
    pop   ecx
8532 IgorA 120
    mcall SF_SYSTEM,SSF_SHUTDOWN
121
    mcall SF_TERMINATE_PROCESS
4268 heavyiron 122
ret
1742 mario79 123
 
4213 heavyiron 124
checkbox:
9456 leency 125
    cmp   [autosave],1
126
    je    .1
4213 heavyiron 127
    mov   [autosave],1
128
    jmp   .draw
129
.1:
130
    mov   [autosave],0
131
.draw:
9456 leency 132
    call  draw_checkbox_flag
133
    jmp   still
4266 heavyiron 134
 
4213 heavyiron 135
draw_window:
8532 IgorA 136
    mcall SF_REDRAW,SSF_BEGIN_DRAW
9456 leency 137
 
138
    mcall SF_GET_SCREEN_SIZE
4213 heavyiron 139
    movzx ecx,ax
4215 heavyiron 140
    shr   eax,17
141
    shl   eax,16
6642 leency 142
    lea   ebx,[eax-(WIN_W/2) shl 16+WIN_W-1]
4215 heavyiron 143
    shr   ecx,1
144
    shl   ecx,16
6642 leency 145
    lea   ecx,[ecx-(WIN_H/2) shl 16+WIN_H-1]
4213 heavyiron 146
 
4215 heavyiron 147
    xor   eax,eax
9456 leency 148
    mov   edx, 0x41000000
149
    mcall ;define and draw window
150
 
151
    DrawWideRectangle 0, 0, WIN_W, WIN_H, 2, 0xA3A7AA
152
    mcall SF_DRAW_RECT, <2,WIN_W-4>, <2,WIN_H-BOT_PANEL_H-2>, 0x202020
153
    mcall SF_DRAW_RECT, <2,WIN_W-4>, , 0x4B4B4B
154
 
9459 leency 155
    mcall SF_DRAW_TEXT, <30,21>, 0x91FFFfff, TEXT_WTITLE
9456 leency 156
    mcall SF_DRAW_TEXT, <55,70>, 0x90FFFfff, TEXT_RDSAVE1
157
    mcall SF_DRAW_TEXT, <55,86>, 0x90FFFfff, TEXT_RDSAVE2
158
    mcall SF_DRAW_TEXT, , 0x81FFFfff, TEXT_CANCEL
159
 
160
	mcall SF_DEFINE_BUTTON, , <2,22>, CANCEL_BUTTON_ID
161
	mcall SF_DEFINE_BUTTON, <32,14>, <70,14>, CHECKBOX_BUTTON_ID
162
	mcall SF_DEFINE_BUTTON, <47,WIN_W-47>, <68,34>, CHECKBOX_BUTTON_ID+BT_NOFRAME
163
    DrawRectangle3D 32, 70, 14, 14, 0x606060, 0xAFAFAF
164
    call draw_checkbox_flag
4213 heavyiron 165
 
9456 leency 166
    stdcall EndButton,  20, 0x4E91C5, HOME_BUTTON_ID,     TEXT_KERNEL, TEXT_HOME
9459 leency 167
    stdcall EndButton, 160, 0x41C166, REBOOT_BUTTON_ID,   TEXT_REBOOT, TEXT_ENTER
9456 leency 168
    stdcall EndButton, 300, 0xC75C54, POWEROFF_BUTTON_ID, TEXT_OFF,    TEXT_END
4213 heavyiron 169
 
9456 leency 170
    mcall SF_REDRAW,SSF_END_DRAW
171
    ret
4213 heavyiron 172
 
9456 leency 173
proc EndButton x, bgcol, id, but_text, hotkey_text
174
    BUTY = WIN_H-60
175
    BUTW = 116
176
    mov ebx,[x]
177
    sub ebx,3
9459 leency 178
    mcall SF_DRAW_RECT, , , 0x202020
9456 leency 179
    mcall SF_DEFINE_BUTTON, <[x],BUTW>, , [id], [bgcol]
180
    ; -strlen(but_text)*8 + BUTW / 2 + x, BUTY+8
181
    stdcall string.length, [but_text]
182
    neg  eax
183
    lea  ebx,[eax*4+BUTW/2]
184
    add  ebx,[x]
185
    mcall SF_DRAW_TEXT, , 0x90FFFfff, [but_text]
186
    add  ebx,1 shl 16
187
    mcall
188
    stdcall string.length, [hotkey_text]
189
    neg  eax
190
    lea  ebx,[eax*3+BUTW/2]
191
    add  ebx,[x]
192
    shl  ebx,16
193
    add  ebx,BUTY+26
194
    mcall SF_DRAW_TEXT, , 0x80FFFfff, [hotkey_text]
195
    ret
196
endp
4215 heavyiron 197
 
9456 leency 198
draw_checkbox_flag:
199
    cmp [autosave],0
200
    je  .flag_unset
201
    cmp [checkbox_img],0
202
    je  .flag_set_but_no_checkbox_img
203
.flag_set:
204
    mcall SF_PUT_IMAGE, [checkbox_img], <13,13>, <33,71>
4213 heavyiron 205
    ret
9456 leency 206
.flag_set_but_no_checkbox_img:
207
    mcall SF_DRAW_RECT, <33,13>, <71,13>, 0xffffff
208
    mcall SF_DRAW_RECT, <34,11>, <72,11>, 0x58C33C
209
    ret
210
.flag_unset:
211
    DrawRectangle3D 33, 71, 12, 12, 0xDDDddd, 0xffffff
212
    mcall SF_DRAW_RECT, <34,12>, <72,12>, 0xFFFfff
213
    ret
4215 heavyiron 214
;---------------------------------------------------------------------
4044 heavyiron 215
include 'data.inc'
4213 heavyiron 216
;---------------------------------------------------------------------
217
IM_END:
218
;---------------------------------------------------------------------
219
align 4
220
proc_info  rb 1024
221
autosave rd 1
222
;---------------------------------------------------------------------
8532 IgorA 223
library_path rb 4096
4213 heavyiron 224
;---------------------------------------------------------------------
225
align 32
9456 leency 226
    rb 4096
4213 heavyiron 227
stacktop:
9456 leency 228
I_END:    ; метка конца программы