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