Subversion Repositories Kolibri OS

Rev

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

Rev 589 Rev 814
1
; int __stdcall GenericBox(DLGTEMPLATE* dlg, void* DlgProc);
1
; int __stdcall GenericBox(DLGTEMPLATE* dlg, void* DlgProc);
2
;       int __stdcall DlgProc(DLGTEMPLATE* dlg, int msg, int param1, int param2);
2
;       int __stdcall DlgProc(DLGTEMPLATE* dlg, int msg, int param1, int param2);
3
 
3
 
4
virtual at 0
4
virtual at 0
5
dlgtemplate:
5
dlgtemplate:
6
; ”« £¨:
6
; ”« £¨:
7
; ¡¨â 0: ¨á¯®«ì§®¢ âì áâ ­¤ àâ­ë¥ æ¢¥â  ¤¨ «®£ 
7
; ¡¨â 0: ¨á¯®«ì§®¢ âì áâ ­¤ àâ­ë¥ æ¢¥â  ¤¨ «®£ 
8
; ¡¨â 1: ¨á¯®«ì§®¢ âì áâ ­¤ àâ­ë¥ æ¢¥â  ¯à¥¤ã¯à¥¦¤¥­¨ï/®è¨¡ª¨
8
; ¡¨â 1: ¨á¯®«ì§®¢ âì áâ ­¤ àâ­ë¥ æ¢¥â  ¯à¥¤ã¯à¥¦¤¥­¨ï/®è¨¡ª¨
9
; (¥á«¨ «î¡®© ¨§ íâ¨å ¡¨â®¢ ãáâ ­®¢«¥­, ¯®«ï main_color,border_color,header_color
9
; (¥á«¨ «î¡®© ¨§ íâ¨å ¡¨â®¢ ãáâ ­®¢«¥­, ¯®«ï main_color,border_color,header_color
10
;  ¨£­®à¨àãîâáï)
10
;  ¨£­®à¨àãîâáï)
-
 
11
; ¡¨â 2: ­¥ à¨á®¢ âì ⥭ì
11
.flags          dd      ?
12
.flags          dd      ?
12
.x              dd      ?
13
.x              dd      ?
13
.y              dd      ?
14
.y              dd      ?
14
.width          dd      ?
15
.width          dd      ?
15
.height         dd      ?
16
.height         dd      ?
16
.border_size_x  dd      ?
17
.border_size_x  dd      ?
17
.border_size_y  dd      ?
18
.border_size_y  dd      ?
18
.title          dd      ?
19
.title          dd      ?
19
.main_color     db      ?
20
.main_color     db      ?
20
.border_color   db      ?
21
.border_color   db      ?
21
.header_color   db      ?
22
.header_color   db      ?
22
                db      ?       ; align
23
                db      ?       ; align
-
 
24
.dataptr        dd      ?       ; used internally, ignored on input
23
.size = $
25
.size = $
24
end virtual
26
end virtual
25
 
27
 
26
GenericBox:
28
GenericBox:
-
 
29
        push    [cursor_x]
-
 
30
        push    [cursor_y]
-
 
31
        push    dword [esp+8+8]
-
 
32
        push    dword [esp+8+8]
-
 
33
        call    ShowGenericBox
-
 
34
        test    eax, eax
-
 
35
        jz      @f
-
 
36
        pop     [cursor_y]
-
 
37
        pop     [cursor_x]
-
 
38
        ret
-
 
39
@@:
-
 
40
        pushad
-
 
41
; message loop
-
 
42
.event:
-
 
43
        push    10
-
 
44
        pop     eax
-
 
45
        int     40h
-
 
46
        dec     eax
-
 
47
        jz      .redraw
-
 
48
        dec     eax
-
 
49
        jz      .key
-
 
50
        jmp     exit
-
 
51
.redraw:
-
 
52
        call    draw_window
-
 
53
        jmp     .event
-
 
54
.key:
-
 
55
        mov     al, 2
-
 
56
        int     40h
-
 
57
        shr     eax, 8
-
 
58
        cmp     al, 0xE0
-
 
59
        jnz     @f
-
 
60
        mov     [bWasE0], 1
-
 
61
        jmp     .event
-
 
62
@@:
-
 
63
        xchg    ah, [bWasE0]
-
 
64
        cmp     al, 0x1D
-
 
65
        jz      .ctrl_down
-
 
66
        cmp     al, 0x9D
-
 
67
        jz      .ctrl_up
-
 
68
        cmp     al, 0x2A
-
 
69
        jz      .lshift_down
-
 
70
        cmp     al, 0xAA
-
 
71
        jz      .lshift_up
-
 
72
        cmp     al, 0x36
-
 
73
        jz      .rshift_down
-
 
74
        cmp     al, 0xB6
-
 
75
        jz      .rshift_up
-
 
76
        cmp     al, 0x38
-
 
77
        jz      .alt_down
-
 
78
        cmp     al, 0xB8
-
 
79
        jz      .alt_up
-
 
80
        mov     ebx, [esp+24h+8]
-
 
81
        mov     ecx, [esp+28h+8]
-
 
82
        push    0
-
 
83
        push    eax
-
 
84
        push    2
-
 
85
        push    ebx
-
 
86
        call    ecx
-
 
87
        test    eax, eax
-
 
88
        jz      .event
-
 
89
        mov     [esp+28], eax
-
 
90
        jmp     .exit
-
 
91
.ctrl_down:
-
 
92
        test    ah, ah
-
 
93
        jnz     .rctrl_down
-
 
94
        or      [ctrlstate], 4
-
 
95
        jmp     .event
-
 
96
.rctrl_down:
-
 
97
        or      [ctrlstate], 8
-
 
98
        jmp     .event
-
 
99
.ctrl_up:
-
 
100
        test    ah, ah
-
 
101
        jnz     .rctrl_up
-
 
102
        and     [ctrlstate], not 4
-
 
103
        jmp     .event
-
 
104
.rctrl_up:
-
 
105
        and     [ctrlstate], not 8
-
 
106
        jmp     .event
-
 
107
.lshift_down:
-
 
108
        test    ah, ah
-
 
109
        jnz     @f
-
 
110
        or      [ctrlstate], 1
-
 
111
@@:     jmp     .event
-
 
112
.lshift_up:
-
 
113
        test    ah, ah
-
 
114
        jnz     @b
-
 
115
        and     [ctrlstate], not 1
-
 
116
        jmp     @b
-
 
117
.rshift_down:
-
 
118
        or      [ctrlstate], 2
-
 
119
        jmp     .event
-
 
120
.rshift_up:
-
 
121
        and     [ctrlstate], not 2
-
 
122
        jmp     .event
-
 
123
.alt_down:
-
 
124
        test    ah, ah
-
 
125
        jnz     .ralt_down
-
 
126
        or      [ctrlstate], 0x10
-
 
127
        jmp     .event
-
 
128
.ralt_down:
-
 
129
        or      [ctrlstate], 0x20
-
 
130
        jmp     .event
-
 
131
.alt_up:
-
 
132
        test    ah, ah
-
 
133
        jnz     .ralt_up
-
 
134
        and     [ctrlstate], not 0x10
-
 
135
        jmp     .event
-
 
136
.ralt_up:
-
 
137
        and     [ctrlstate], not 0x20
-
 
138
        jmp     .event
-
 
139
.exit:
-
 
140
        popad
-
 
141
        push    eax
-
 
142
        push    0
-
 
143
        push    dword [esp+12+8]
-
 
144
        call    HideGenericBox
-
 
145
        pop     eax
-
 
146
        pop     [cursor_y]
-
 
147
        pop     [cursor_x]
-
 
148
        pushad
-
 
149
        call    draw_image
-
 
150
        popad
-
 
151
        ret     8
-
 
152
 
-
 
153
; int __stdcall ShowGenericBox(DLGTEMPLATE* dlg, void* DlgProc);
-
 
154
ShowGenericBox:
27
        pushad
155
        pushad
28
        mov     ebx, [esp+20h+4]
156
        mov     ebx, [esp+20h+4]
29
; center window if required
157
; center window if required
30
        push    [ebx+dlgtemplate.x]
158
        push    [ebx+dlgtemplate.x]
31
        push    [ebx+dlgtemplate.y]
159
        push    [ebx+dlgtemplate.y]
32
        cmp     [ebx+dlgtemplate.x], -1
160
        cmp     [ebx+dlgtemplate.x], -1
33
        jnz     @f
161
        jnz     @f
34
        mov     eax, [cur_width]
162
        mov     eax, [cur_width]
35
        sub     eax, [ebx+dlgtemplate.width]
163
        sub     eax, [ebx+dlgtemplate.width]
36
        shr     eax, 1
164
        shr     eax, 1
37
        mov     [ebx+dlgtemplate.x], eax
165
        mov     [ebx+dlgtemplate.x], eax
38
@@:
166
@@:
39
        cmp     [ebx+dlgtemplate.y], -1
167
        cmp     [ebx+dlgtemplate.y], -1
40
        jnz     @f
168
        jnz     @f
41
        mov     eax, [cur_height]
169
        mov     eax, [cur_height]
42
        sub     eax, [ebx+dlgtemplate.height]
170
        sub     eax, [ebx+dlgtemplate.height]
43
        shr     eax, 1
171
        shr     eax, 1
44
        mov     [ebx+dlgtemplate.y], eax
172
        mov     [ebx+dlgtemplate.y], eax
45
@@:
173
@@:
46
; some checks
174
; some checks
47
        mov     eax, [ebx+dlgtemplate.x]
175
        mov     eax, [ebx+dlgtemplate.x]
48
        cmp     eax, 1
176
        cmp     eax, 1
49
        jl      .sizeerr
177
        jl      .sizeerr
50
        add     eax, [ebx+dlgtemplate.width]
178
        add     eax, [ebx+dlgtemplate.width]
51
        cmp     eax, [cur_width]
179
        cmp     eax, [cur_width]
52
        jge     .sizeerr
180
        jge     .sizeerr
53
        mov     eax, [ebx+dlgtemplate.y]
181
        mov     eax, [ebx+dlgtemplate.y]
54
        cmp     eax, 1
182
        cmp     eax, 1
55
        jl      .sizeerr
183
        jl      .sizeerr
56
        add     eax, [ebx+dlgtemplate.height]
184
        add     eax, [ebx+dlgtemplate.height]
57
        cmp     eax, [cur_height]
185
        cmp     eax, [cur_height]
58
        jge     .sizeerr
186
        jge     .sizeerr
59
        cmp     [ebx+dlgtemplate.border_size_x], 1
187
        cmp     [ebx+dlgtemplate.border_size_x], 1
60
        jl      .sizeerr
188
        jl      .sizeerr
61
        cmp     [ebx+dlgtemplate.border_size_y], 1
189
        cmp     [ebx+dlgtemplate.border_size_y], 1
62
        jge     .sizeok
190
        jge     .sizeok
63
.sizeerr:
191
.sizeerr:
64
        pop     [ebx+dlgtemplate.y]
192
        pop     [ebx+dlgtemplate.y]
65
        pop     [ebx+dlgtemplate.x]
193
        pop     [ebx+dlgtemplate.x]
66
        popad
194
        popad
67
        or      eax, -1
195
        or      eax, -1
68
        ret     8
196
        ret     8
69
.sizeok:
197
.sizeok:
70
; set color if required
198
; set color if required
71
        test    byte [ebx+dlgtemplate.flags], 1
199
        test    byte [ebx+dlgtemplate.flags], 1
72
        jz      @f
200
        jz      @f
73
        mov     edi, dialog_colors
201
        mov     edi, dialog_colors
74
        jmp     .setcolor
202
        jmp     .setcolor
75
@@:
203
@@:
76
        test    byte [ebx+dlgtemplate.flags], 2
204
        test    byte [ebx+dlgtemplate.flags], 2
77
        jz      @f
205
        jz      @f
78
        mov     edi, warning_colors
206
        mov     edi, warning_colors
79
.setcolor:
207
.setcolor:
80
        mov     al, [edi + dialog_main_color-dialog_colors]
208
        mov     al, [edi + dialog_main_color-dialog_colors]
81
        mov     [ebx+dlgtemplate.main_color], al
209
        mov     [ebx+dlgtemplate.main_color], al
82
        mov     al, [edi + dialog_border_color-dialog_colors]
210
        mov     al, [edi + dialog_border_color-dialog_colors]
83
        mov     [ebx+dlgtemplate.border_color], al
211
        mov     [ebx+dlgtemplate.border_color], al
84
        mov     al, [edi + dialog_header_color-dialog_colors]
212
        mov     al, [edi + dialog_header_color-dialog_colors]
85
        mov     [ebx+dlgtemplate.header_color], al
213
        mov     [ebx+dlgtemplate.header_color], al
86
@@:
214
@@:
87
; allocate memory for data under dialog
215
; allocate memory for data under dialog
88
; for 'No memory' dialog use static data area
216
; for 'No memory' dialog use static data area
89
        mov     ebp, nomem_dlgsavearea
217
        mov     eax, nomem_dlgsavearea
90
        cmp     ebx, nomem_dlgdata
218
        cmp     ebx, nomem_dlgdata
91
        jz      .allocated
219
        jz      .allocated
92
        mov     eax, [ebx+dlgtemplate.width]
220
        mov     eax, [ebx+dlgtemplate.width]
93
        add     eax, [ebx+dlgtemplate.border_size_x]
221
        add     eax, [ebx+dlgtemplate.border_size_x]
94
        add     eax, [ebx+dlgtemplate.border_size_x]
222
        add     eax, [ebx+dlgtemplate.border_size_x]
95
        inc     eax
223
        inc     eax
96
        inc     eax
224
        inc     eax
97
        mov     edx, [ebx+dlgtemplate.height]
225
        mov     edx, [ebx+dlgtemplate.height]
98
        add     edx, [ebx+dlgtemplate.border_size_y]
226
        add     edx, [ebx+dlgtemplate.border_size_y]
99
        add     edx, [ebx+dlgtemplate.border_size_y]
227
        add     edx, [ebx+dlgtemplate.border_size_y]
100
        inc     edx
228
        inc     edx
101
        mul     edx
229
        mul     edx
102
        lea     ecx, [eax*2]
230
        lea     ecx, [eax*2+8]
103
        call    xpgalloc
231
        call    xpgalloc
104
        test    eax, eax
232
        test    eax, eax
105
        jnz     @f
233
        jnz     @f
106
        pop     [ebx+dlgtemplate.y]
234
        pop     [ebx+dlgtemplate.y]
107
        pop     [ebx+dlgtemplate.x]
235
        pop     [ebx+dlgtemplate.x]
108
        popad
236
        popad
109
        or      eax, -1
237
        or      eax, -1
110
        ret     8
238
        ret     8
111
@@:
239
@@:
112
        mov     ebp, eax
-
 
113
.allocated:
240
.allocated:
-
 
241
        mov     [ebx+dlgtemplate.dataptr], eax
-
 
242
        pop     dword [eax+4]
-
 
243
        pop     dword [eax]
-
 
244
        lea     ebp, [eax+8]
114
; save data
245
; save data
115
        mov     eax, [ebx+dlgtemplate.y]
246
        mov     eax, [ebx+dlgtemplate.y]
116
        add     eax, [ebx+dlgtemplate.height]
247
        add     eax, [ebx+dlgtemplate.height]
117
        add     eax, [ebx+dlgtemplate.border_size_y]
248
        add     eax, [ebx+dlgtemplate.border_size_y]
118
        inc     eax
249
        inc     eax
119
        push    eax
250
        push    eax
120
        mov     eax, [ebx+dlgtemplate.x]
251
        mov     eax, [ebx+dlgtemplate.x]
121
        add     eax, [ebx+dlgtemplate.width]
252
        add     eax, [ebx+dlgtemplate.width]
122
        add     eax, [ebx+dlgtemplate.border_size_x]
253
        add     eax, [ebx+dlgtemplate.border_size_x]
123
        inc     eax
254
        inc     eax
124
        inc     eax
255
        inc     eax
125
        push    eax
256
        push    eax
126
        mov     eax, [ebx+dlgtemplate.y]
257
        mov     eax, [ebx+dlgtemplate.y]
127
        sub     eax, [ebx+dlgtemplate.border_size_y]
258
        sub     eax, [ebx+dlgtemplate.border_size_y]
128
        push    eax
259
        push    eax
129
        mov     eax, [ebx+dlgtemplate.x]
260
        mov     eax, [ebx+dlgtemplate.x]
130
        sub     eax, [ebx+dlgtemplate.border_size_x]
261
        sub     eax, [ebx+dlgtemplate.border_size_x]
131
        push    eax
262
        push    eax
132
        call    save_console_data
263
        call    save_console_data
133
; draw shadow
264
; draw shadow
-
 
265
        test    byte [ebx+dlgtemplate.flags], 4
-
 
266
        jnz     .noshadow
134
        mov     eax, [ebx+dlgtemplate.x]
267
        mov     eax, [ebx+dlgtemplate.x]
135
        sub     eax, [ebx+dlgtemplate.border_size_x]
268
        sub     eax, [ebx+dlgtemplate.border_size_x]
136
        ja      @f
269
        ja      @f
137
        xor     eax, eax
270
        xor     eax, eax
138
@@:
271
@@:
139
        push    eax     ; save real window left
-
 
140
        inc     eax
272
        inc     eax
141
        inc     eax
273
        inc     eax
142
        mov     edx, [ebx+dlgtemplate.y]
274
        mov     edx, [ebx+dlgtemplate.y]
143
        sub     edx, [ebx+dlgtemplate.border_size_y]
275
        sub     edx, [ebx+dlgtemplate.border_size_y]
144
        ja      @f
276
        ja      @f
145
        xor     edx, edx
277
        xor     edx, edx
146
@@:
278
@@:
147
        push    edx     ; save real window top
-
 
148
        inc     edx
279
        inc     edx
149
        call    get_console_ptr
280
        call    get_console_ptr
150
        mov     ecx, [ebx+dlgtemplate.y]
281
        mov     ecx, [ebx+dlgtemplate.y]
151
        add     ecx, [ebx+dlgtemplate.height]
282
        add     ecx, [ebx+dlgtemplate.height]
152
        add     ecx, [ebx+dlgtemplate.border_size_y]
283
        add     ecx, [ebx+dlgtemplate.border_size_y]
153
        inc     ecx
284
        inc     ecx
154
        cmp     ecx, [cur_height]
285
        cmp     ecx, [cur_height]
155
        jb      @f
286
        jb      @f
156
        mov     ecx, [cur_height]
287
        mov     ecx, [cur_height]
157
@@:
288
@@:
158
        sub     ecx, edx
289
        sub     ecx, edx
159
        mov     edx, ecx
290
        mov     edx, ecx
160
        mov     ecx, [ebx+dlgtemplate.x]
291
        mov     ecx, [ebx+dlgtemplate.x]
161
        add     ecx, [ebx+dlgtemplate.width]
292
        add     ecx, [ebx+dlgtemplate.width]
162
        add     ecx, [ebx+dlgtemplate.border_size_x]
293
        add     ecx, [ebx+dlgtemplate.border_size_x]
163
        inc     ecx
294
        inc     ecx
164
        inc     ecx
295
        inc     ecx
165
        cmp     ecx, [cur_width]
296
        cmp     ecx, [cur_width]
166
        jb      @f
297
        jb      @f
167
        mov     ecx, [cur_width]
298
        mov     ecx, [cur_width]
168
@@:
299
@@:
169
        sub     ecx, eax
300
        sub     ecx, eax
170
        mov     eax, ecx
301
        mov     eax, ecx
171
.shadow_loop:
302
.shadow_loop:
172
        mov     ecx, eax
303
        mov     ecx, eax
173
        push    edi
304
        push    edi
174
.sl1:
305
.sl1:
175
        inc     edi
306
        inc     edi
176
        test    byte [edi], 0x0F
307
        test    byte [edi], 0x0F
177
        jnz     @f
308
        jnz     @f
178
        or      byte [edi], 8
309
        or      byte [edi], 8
179
@@:
310
@@:
180
        and     byte [edi], 0x0F
311
        and     byte [edi], 0x0F
181
        inc     edi
312
        inc     edi
182
        loop    .sl1
313
        loop    .sl1
183
        pop     edi
314
        pop     edi
184
        add     edi, [cur_width]
315
        add     edi, [cur_width]
185
        add     edi, [cur_width]
316
        add     edi, [cur_width]
186
        dec     edx
317
        dec     edx
187
        jnz     .shadow_loop
318
        jnz     .shadow_loop
-
 
319
.noshadow:
-
 
320
        popad
-
 
321
        push    dword [esp+8]
-
 
322
        push    dword [esp+8]
-
 
323
        call    DrawGenericBox
-
 
324
        xor     eax, eax
-
 
325
        ret     8
-
 
326
 
-
 
327
; void __stdcall DrawGenericBox(DLGDATA* dlg, void* DlgProc)
-
 
328
DrawGenericBox:
-
 
329
        pushad
-
 
330
        mov     ebx, [esp+24h]
188
; draw area background
331
; draw area background
-
 
332
        mov     eax, [ebx+dlgtemplate.x]
-
 
333
        sub     eax, [ebx+dlgtemplate.border_size_x]
189
        pop     edx
334
        ja      @f
-
 
335
        xor     eax, eax
-
 
336
@@:
-
 
337
        mov     edx, [ebx+dlgtemplate.y]
-
 
338
        sub     edx, [ebx+dlgtemplate.border_size_y]
190
        pop     eax
339
        ja      @f
-
 
340
        xor     edx, edx
-
 
341
@@:
191
        call    get_console_ptr
342
        call    get_console_ptr
192
        mov     ecx, [ebx+dlgtemplate.x]
343
        mov     ecx, [ebx+dlgtemplate.x]
193
        add     ecx, [ebx+dlgtemplate.width]
344
        add     ecx, [ebx+dlgtemplate.width]
194
        add     ecx, [ebx+dlgtemplate.border_size_x]
345
        add     ecx, [ebx+dlgtemplate.border_size_x]
195
        cmp     ecx, [cur_width]
346
        cmp     ecx, [cur_width]
196
        jb      @f
347
        jb      @f
197
        mov     ecx, [cur_width]
348
        mov     ecx, [cur_width]
198
@@:
349
@@:
199
        sub     ecx, eax
350
        sub     ecx, eax
200
        mov     esi, ecx
351
        mov     esi, ecx
201
        mov     ecx, [ebx+dlgtemplate.y]
352
        mov     ecx, [ebx+dlgtemplate.y]
202
        add     ecx, [ebx+dlgtemplate.height]
353
        add     ecx, [ebx+dlgtemplate.height]
203
        add     ecx, [ebx+dlgtemplate.border_size_y]
354
        add     ecx, [ebx+dlgtemplate.border_size_y]
204
        cmp     ecx, [cur_height]
355
        cmp     ecx, [cur_height]
205
        jb      @f
356
        jb      @f
206
        mov     ecx, [cur_height]
357
        mov     ecx, [cur_height]
207
@@:
358
@@:
208
        sub     ecx, edx
359
        sub     ecx, edx
209
        mov     edx, ecx
360
        mov     edx, ecx
210
        mov     al, ' '
361
        mov     al, ' '
211
        mov     ah, [ebx+dlgtemplate.border_color]
362
        mov     ah, [ebx+dlgtemplate.border_color]
212
.1:
363
.1:
213
        mov     ecx, esi
364
        mov     ecx, esi
214
        push    edi
365
        push    edi
215
        rep     stosw
366
        rep     stosw
216
        pop     edi
367
        pop     edi
217
        add     edi, [cur_width]
368
        add     edi, [cur_width]
218
        add     edi, [cur_width]
369
        add     edi, [cur_width]
219
        dec     edx
370
        dec     edx
220
        jnz     .1
371
        jnz     .1
221
; draw border
372
; draw border
222
        mov     eax, [ebx+dlgtemplate.x]
373
        mov     eax, [ebx+dlgtemplate.x]
223
        dec     eax
374
        dec     eax
224
        mov     edx, [ebx+dlgtemplate.y]
375
        mov     edx, [ebx+dlgtemplate.y]
225
        dec     edx
376
        dec     edx
226
        call    get_console_ptr
377
        call    get_console_ptr
227
        mov     edx, [ebx+dlgtemplate.height]
378
        mov     edx, [ebx+dlgtemplate.height]
228
        inc     edx
379
        inc     edx
229
        inc     edx
380
        inc     edx
230
        mov     ah, [ebx+dlgtemplate.border_color]
381
        mov     ah, [ebx+dlgtemplate.border_color]
231
        push    ebx
382
        push    ebx
232
        mov     ebx, [ebx+dlgtemplate.width]
383
        mov     ebx, [ebx+dlgtemplate.width]
233
        inc     ebx
384
        inc     ebx
234
        inc     ebx
385
        inc     ebx
235
        call    draw_border
386
        call    draw_border
236
        pop     ebx
387
        pop     ebx
237
; draw header
388
; draw header
238
        mov     esi, [ebx+dlgtemplate.title]
389
        mov     esi, [ebx+dlgtemplate.title]
239
        test    esi, esi
390
        test    esi, esi
240
        jz      .noheader
391
        jz      .noheader
241
        cmp     byte [esi], 0
392
        cmp     byte [esi], 0
242
        jz      .noheader
393
        jz      .noheader
243
        push    esi
394
        push    esi
244
@@:     lodsb
395
@@:     lodsb
245
        test    al, al
396
        test    al, al
246
        jnz     @b
397
        jnz     @b
247
        mov     eax, esi
398
        mov     eax, esi
248
        pop     esi
399
        pop     esi
249
        sub     eax, esi
400
        sub     eax, esi
250
        inc     eax     ; eax = ¤«¨­  § £®«®¢ª  + 2
401
        inc     eax     ; eax = ¤«¨­  § £®«®¢ª  + 2
251
        mov     ecx, [ebx+dlgtemplate.width]
402
        mov     ecx, [ebx+dlgtemplate.width]
252
        cmp     eax, ecx
403
        cmp     eax, ecx
253
        jbe     .fullhea
404
        jbe     .fullhea
254
        sub     ecx, 5
405
        sub     ecx, 5
255
        jb      .noheader
406
        jb      .noheader
256
        xor     edx, edx
407
        xor     edx, edx
257
        jmp     .drawhea
408
        jmp     .drawhea
258
.fullhea:
409
.fullhea:
259
        mov     edx, ecx
410
        mov     edx, ecx
260
        sub     edx, eax
411
        sub     edx, eax
261
        shr     edx, 1
412
        shr     edx, 1
262
.drawhea:
413
.drawhea:
263
        mov     eax, [ebx+dlgtemplate.x]
414
        mov     eax, [ebx+dlgtemplate.x]
264
        add     eax, edx
415
        add     eax, edx
265
        mov     edx, [ebx+dlgtemplate.y]
416
        mov     edx, [ebx+dlgtemplate.y]
266
        dec     edx
417
        dec     edx
267
        call    get_console_ptr
418
        call    get_console_ptr
268
        mov     ah, [ebx+dlgtemplate.header_color]
419
        mov     ah, [ebx+dlgtemplate.header_color]
269
        mov     al, ' '
420
        mov     al, ' '
270
        stosw
421
        stosw
271
.2:
422
.2:
272
        dec     ecx
423
        dec     ecx
273
        jz	.3
424
        jz	.3
274
        lodsb
425
        lodsb
275
        test    al, al
426
        test    al, al
276
        jz      .4
427
        jz      .4
277
        stosw
428
        stosw
278
        jmp     .2
429
        jmp     .2
279
.3:
430
.3:
280
        mov     al, '.'
431
        mov     al, '.'
281
        stosw
432
        stosw
282
        stosw
433
        stosw
283
        stosw
434
        stosw
284
.4:
435
.4:
285
        mov     al, ' '
436
        mov     al, ' '
286
        stosw
437
        stosw
287
.noheader:
438
.noheader:
288
; draw window background
439
; draw window background
289
        mov     eax, [ebx+dlgtemplate.x]
440
        mov     eax, [ebx+dlgtemplate.x]
290
        mov     edx, [ebx+dlgtemplate.y]
441
        mov     edx, [ebx+dlgtemplate.y]
291
        call    get_console_ptr
442
        call    get_console_ptr
292
        mov     ah, [ebx+dlgtemplate.main_color]
443
        mov     ah, [ebx+dlgtemplate.main_color]
293
        mov     al, ' '
444
        mov     al, ' '
294
        mov     edx, [ebx+dlgtemplate.height]
445
        mov     edx, [ebx+dlgtemplate.height]
295
@@:
446
@@:
296
        mov     ecx, [ebx+dlgtemplate.width]
447
        mov     ecx, [ebx+dlgtemplate.width]
297
        push    edi
448
        push    edi
298
        rep     stosw
449
        rep     stosw
299
        pop     edi
450
        pop     edi
300
        add     edi, [cur_width]
451
        add     edi, [cur_width]
301
        add     edi, [cur_width]
452
        add     edi, [cur_width]
302
        dec     edx
453
        dec     edx
303
        jnz     @b
454
        jnz     @b
304
; send redraw message
455
; send redraw message
305
        mov     eax, [esp+28h+8]
456
        mov     eax, [esp+28h]
306
        push    ebx ebp
-
 
307
        push    0
457
        push    0
308
        push    0
458
        push    0
309
        push    1
459
        push    1
310
        push    ebx
460
        push    ebx
311
        call    eax
461
        call    eax
312
        call    draw_image
462
        call    draw_image
313
        pop     ebp ebx
-
 
314
; message loop
-
 
315
.event:
-
 
316
        push    10
-
 
317
        pop     eax
463
        popad
318
        int     40h
-
 
319
        dec     eax
-
 
320
        jz      .redraw
-
 
321
        dec     eax
-
 
322
        jz      .key
-
 
323
        jmp     exit
-
 
324
.redraw:
-
 
325
        push    ebx ebp
-
 
326
        call    draw_window
-
 
327
        pop     ebp ebx
-
 
328
        jmp     .event
-
 
329
.key:
-
 
330
        mov     al, 2
-
 
331
        int     40h
464
        ret     8
332
        shr     eax, 8
-
 
333
        cmp     al, 0xE0
-
 
334
        jnz     @f
-
 
335
        mov     [bWasE0], 1
-
 
336
        jmp     .event
-
 
337
@@:
465
 
338
        xchg    ah, [bWasE0]
-
 
339
        cmp     al, 0x1D
-
 
340
        jz      .ctrl_down
-
 
341
        cmp     al, 0x9D
-
 
342
        jz      .ctrl_up
-
 
343
        cmp     al, 0x2A
-
 
344
        jz      .lshift_down
-
 
345
        cmp     al, 0xAA
-
 
346
        jz      .lshift_up
-
 
347
        cmp     al, 0x36
-
 
348
        jz      .rshift_down
-
 
349
        cmp     al, 0xB6
-
 
350
        jz      .rshift_up
-
 
351
        cmp     al, 0x38
-
 
352
        jz      .alt_down
-
 
353
        cmp     al, 0xB8
-
 
354
        jz      .alt_up
-
 
355
        mov     ecx, [esp+28h+8]
466
; void __stdcall HideGenericBox(DLGTEMPLATE* dlg, int bRedrawWindow);
356
        push    ebx ebp
-
 
357
        push    0
-
 
358
        push    eax
-
 
359
        push    2
-
 
360
        push    ebx
-
 
361
        call    ecx
-
 
362
        pop     ebp ebx
-
 
363
        test    eax, eax
-
 
364
        jz      .event
-
 
365
        mov     [esp+8+28], eax
-
 
366
        jmp     .exit
-
 
367
.ctrl_down:
-
 
368
        test    ah, ah
-
 
369
        jnz     .rctrl_down
-
 
370
        or      [ctrlstate], 4
-
 
371
        jmp     .event
-
 
372
.rctrl_down:
467
HideGenericBox:
373
        or      [ctrlstate], 8
-
 
374
        jmp     .event
-
 
375
.ctrl_up:
-
 
376
        test    ah, ah
-
 
377
        jnz     .rctrl_up
-
 
378
        and     [ctrlstate], not 4
-
 
379
        jmp     .event
-
 
380
.rctrl_up:
-
 
381
        and     [ctrlstate], not 8
468
; void __stdcall HideDialogBox(DLGDATA* dlg, int bRedrawWindow);
382
        jmp     .event
-
 
383
.lshift_down:
469
HideDialogBox:
384
        test    ah, ah
-
 
385
        jnz     @f
-
 
386
        or      [ctrlstate], 1
-
 
387
@@:     jmp     .event
-
 
388
.lshift_up:
-
 
389
        test    ah, ah
-
 
390
        jnz     @b
-
 
391
        and     [ctrlstate], not 1
-
 
392
        jmp     @b
470
        pushad
393
.rshift_down:
-
 
394
        or      [ctrlstate], 2
471
        mov     ebx, [esp+24h]
395
        jmp     .event
-
 
396
.rshift_up:
-
 
397
        and     [ctrlstate], not 2
-
 
398
        jmp     .event
-
 
399
.alt_down:
-
 
400
        test    ah, ah
-
 
401
        jnz     .ralt_down
-
 
402
        or      [ctrlstate], 0x10
-
 
403
        jmp     .event
-
 
404
.ralt_down:
-
 
405
        or      [ctrlstate], 0x20
472
        mov     ebp, [ebx+dlgtemplate.dataptr]
406
        jmp     .event
-
 
407
.alt_up:
-
 
408
        test    ah, ah
473
        add     ebp, 8
409
        jnz     .ralt_up
-
 
410
        and     [ctrlstate], not 0x10
-
 
411
        jmp     .event
-
 
412
.ralt_up:
-
 
413
        and     [ctrlstate], not 0x20
-
 
414
        jmp     .event
-
 
415
.exit:
-
 
416
; restore data
474
; restore data
417
        mov     eax, [ebx+dlgtemplate.y]
475
        mov     eax, [ebx+dlgtemplate.y]
418
        add     eax, [ebx+dlgtemplate.height]
476
        add     eax, [ebx+dlgtemplate.height]
419
        add     eax, [ebx+dlgtemplate.border_size_y]
477
        add     eax, [ebx+dlgtemplate.border_size_y]
420
        inc     eax
478
        inc     eax
421
        push    eax
479
        push    eax
422
        mov     eax, [ebx+dlgtemplate.x]
480
        mov     eax, [ebx+dlgtemplate.x]
423
        add     eax, [ebx+dlgtemplate.width]
481
        add     eax, [ebx+dlgtemplate.width]
424
        add     eax, [ebx+dlgtemplate.border_size_x]
482
        add     eax, [ebx+dlgtemplate.border_size_x]
425
        inc     eax
483
        inc     eax
426
        inc     eax
484
        inc     eax
427
        push    eax
485
        push    eax
428
        mov     eax, [ebx+dlgtemplate.y]
486
        mov     eax, [ebx+dlgtemplate.y]
429
        sub     eax, [ebx+dlgtemplate.border_size_y]
487
        sub     eax, [ebx+dlgtemplate.border_size_y]
430
        push    eax
488
        push    eax
431
        mov     eax, [ebx+dlgtemplate.x]
489
        mov     eax, [ebx+dlgtemplate.x]
432
        sub     eax, [ebx+dlgtemplate.border_size_x]
490
        sub     eax, [ebx+dlgtemplate.border_size_x]
433
        push    eax
491
        push    eax
434
        call    restore_console_data
492
        call    restore_console_data
435
        call    draw_keybar
493
        call    draw_keybar
-
 
494
        lea     ecx, [ebp-8]
-
 
495
        push    dword [ecx]
-
 
496
        push    dword [ecx+4]
-
 
497
        pop     [ebx+dlgtemplate.y]
-
 
498
        pop     [ebx+dlgtemplate.x]
436
        cmp     ebx, nomem_dlgdata
499
        cmp     ebx, nomem_dlgdata
437
        jz      @f
500
        jz      @f
438
        mov     ecx, ebp
-
 
439
        call    pgfree
501
        call    pgfree
440
@@:
502
@@:
441
        pop     [ebx+dlgtemplate.y]
-
 
442
        pop     [ebx+dlgtemplate.x]
-
 
443
        or      [cursor_x], -1
503
        or      [cursor_x], -1
444
        or      [cursor_y], -1
504
        or      [cursor_y], -1
-
 
505
        cmp     dword [esp+28h], 0
-
 
506
        jz      @f
445
        call    draw_image
507
        call    draw_image
-
 
508
@@:
446
        popad
509
        popad
447
        ret     8
510
        ret     8
448
 
511
 
449
save_console_data:
512
save_console_data:
450
        cmp     dword [esp+4], 0
513
        cmp     dword [esp+4], 0
451
        jge     @f
514
        jge     @f
452
        and     dword [esp+4], 0
515
        and     dword [esp+4], 0
453
@@:
516
@@:
454
        cmp     dword [esp+8], 0
517
        cmp     dword [esp+8], 0
455
        jge     @f
518
        jge     @f
456
        and     dword [esp+8], 0
519
        and     dword [esp+8], 0
457
@@:
520
@@:
458
        mov     eax, [esp+12]
521
        mov     eax, [esp+12]
459
        cmp     eax, [cur_width]
522
        cmp     eax, [cur_width]
460
        jbe     @f
523
        jbe     @f
461
        mov     eax, [cur_width]
524
        mov     eax, [cur_width]
462
@@:
525
@@:
463
        sub     eax, [esp+4]
526
        sub     eax, [esp+4]
464
        ja      @f
527
        ja      @f
465
        ret     16
528
        ret     16
466
@@:
529
@@:
467
        mov     [esp+12], eax
530
        mov     [esp+12], eax
468
        mov     eax, [esp+16]
531
        mov     eax, [esp+16]
469
        cmp     eax, [cur_height]
532
        cmp     eax, [cur_height]
470
        jbe     @f
533
        jbe     @f
471
        mov     eax, [cur_height]
534
        mov     eax, [cur_height]
472
@@:
535
@@:
473
        sub     eax, [esp+8]
536
        sub     eax, [esp+8]
474
        ja      @f
537
        ja      @f
475
        ret     16
538
        ret     16
476
@@:
539
@@:
477
        mov     [esp+16], eax
540
        mov     [esp+16], eax
478
        mov     eax, [esp+4]
541
        mov     eax, [esp+4]
479
        mov     edx, [esp+8]
542
        mov     edx, [esp+8]
480
        call    get_console_ptr
543
        call    get_console_ptr
481
        mov     esi, edi
544
        mov     esi, edi
482
        mov     edi, ebp
545
        mov     edi, ebp
483
.l:
546
.l:
484
        mov     ecx, [esp+12]
547
        mov     ecx, [esp+12]
485
        push    esi
548
        push    esi
486
        shr     ecx, 1
549
        shr     ecx, 1
487
        rep     movsd
550
        rep     movsd
488
        adc     ecx, ecx
551
        adc     ecx, ecx
489
        rep     movsw
552
        rep     movsw
490
        pop     esi
553
        pop     esi
491
        add     esi, [cur_width]
554
        add     esi, [cur_width]
492
        add     esi, [cur_width]
555
        add     esi, [cur_width]
493
        dec     dword [esp+16]
556
        dec     dword [esp+16]
494
        jnz     .l
557
        jnz     .l
495
        ret     16
558
        ret     16
496
 
559
 
497
restore_console_data:
560
restore_console_data:
498
        cmp     dword [esp+4], 0
561
        cmp     dword [esp+4], 0
499
        jge     @f
562
        jge     @f
500
        and     dword [esp+4], 0
563
        and     dword [esp+4], 0
501
@@:
564
@@:
502
        cmp     dword [esp+8], 0
565
        cmp     dword [esp+8], 0
503
        jge     @f
566
        jge     @f
504
        and     dword [esp+8], 0
567
        and     dword [esp+8], 0
505
@@:
568
@@:
506
        mov     eax, [esp+12]
569
        mov     eax, [esp+12]
507
        cmp     eax, [cur_width]
570
        cmp     eax, [cur_width]
508
        jbe     @f
571
        jbe     @f
509
        mov     eax, [cur_width]
572
        mov     eax, [cur_width]
510
@@:
573
@@:
511
        sub     eax, [esp+4]
574
        sub     eax, [esp+4]
512
        ja      @f
575
        ja      @f
513
        ret     16
576
        ret     16
514
@@:
577
@@:
515
        mov     [esp+12], eax
578
        mov     [esp+12], eax
516
        mov     eax, [esp+16]
579
        mov     eax, [esp+16]
517
        cmp     eax, [cur_height]
580
        cmp     eax, [cur_height]
518
        jbe     @f
581
        jbe     @f
519
        mov     eax, [cur_height]
582
        mov     eax, [cur_height]
520
@@:
583
@@:
521
        sub     eax, [esp+8]
584
        sub     eax, [esp+8]
522
        ja      @f
585
        ja      @f
523
        ret     16
586
        ret     16
524
@@:
587
@@:
525
        mov     [esp+16], eax
588
        mov     [esp+16], eax
526
        mov     eax, [esp+4]
589
        mov     eax, [esp+4]
527
        mov     edx, [esp+8]
590
        mov     edx, [esp+8]
528
        call    get_console_ptr
591
        call    get_console_ptr
529
        mov     esi, ebp
592
        mov     esi, ebp
530
.l:
593
.l:
531
        mov     ecx, [esp+12]
594
        mov     ecx, [esp+12]
532
        push    edi
595
        push    edi
533
        shr     ecx, 1
596
        shr     ecx, 1
534
        rep     movsd
597
        rep     movsd
535
        adc     ecx, ecx
598
        adc     ecx, ecx
536
        rep     movsw
599
        rep     movsw
537
        pop     edi
600
        pop     edi
538
        add     edi, [cur_width]
601
        add     edi, [cur_width]
539
        add     edi, [cur_width]
602
        add     edi, [cur_width]
540
        dec     dword [esp+16]
603
        dec     dword [esp+16]
541
        jnz     .l
604
        jnz     .l
542
        ret     16
605
        ret     16
543
 
606
 
544
; int __stdcall menu(void* variants, const char* title, unsigned flags);
607
; int __stdcall menu(void* variants, const char* title, unsigned flags);
545
; variants 㪠§ë¢ ¥â ­  ⥪ã騩 í«¥¬¥­â ¢ ¤¢ãá¢ï§­®¬ «¨­¥©­®¬ ᯨ᪥
608
; variants 㪠§ë¢ ¥â ­  ⥪ã騩 í«¥¬¥­â ¢ ¤¢ãá¢ï§­®¬ «¨­¥©­®¬ ᯨ᪥
546
menu:
609
menu:
547
        pop     eax
610
        pop     eax
548
        push    [cur_height]
611
        push    [cur_height]
549
        push    [cur_width]
612
        push    [cur_width]
550
        push    0
613
        push    0
551
        push    0
614
        push    0
552
        push    eax
615
        push    eax
553
 
616
 
554
; int __stdcall menu_centered_in(unsigned left, unsigned top, unsigned width, unsigned height,
617
; int __stdcall menu_centered_in(unsigned left, unsigned top, unsigned width, unsigned height,
555
;       void* variants, const char* title, unsigned flags);
618
;       void* variants, const char* title, unsigned flags);
556
menu_centered_in:
619
menu_centered_in:
557
        pushad
620
        pushad
558
        mov     ecx, 56
621
        mov     ecx, 60
559
; 36 bytes for dlgtemplate + additional:
622
; 40 bytes for dlgtemplate + additional:
560
; +36: dd cur_variant
623
; +40: dd cur_variant
561
; +40: dd num_variants
624
; +44: dd num_variants
562
; +44: dd begin_variant
625
; +48: dd begin_variant
563
; +48: dd end_variant
626
; +52: dd end_variant
564
; +52: dd cur_variant_idx
627
; +56: dd cur_variant_idx
565
        call    xpgalloc
628
        call    xpgalloc
566
        test    eax, eax
629
        test    eax, eax
567
        jnz     @f
630
        jnz     @f
568
.ret_bad:
631
.ret_bad:
569
        popad
632
        popad
570
        or      eax, -1
633
        or      eax, -1
571
        ret     28
634
        ret     28
572
@@:
635
@@:
573
        mov     ebx, eax
636
        mov     ebx, eax
574
        mov     eax, 1
637
        mov     eax, 1
575
        test    byte [esp+20h+28], 1
638
        test    byte [esp+20h+28], 1
576
        jz      @f
639
        jz      @f
577
        mov     al, 3
640
        mov     al, 3
578
@@:
641
@@:
579
        mov     [ebx+dlgtemplate.border_size_x], eax
642
        mov     [ebx+dlgtemplate.border_size_x], eax
580
        inc     eax
643
        inc     eax
581
        shr     eax, 1
644
        shr     eax, 1
582
        mov     [ebx+dlgtemplate.border_size_y], eax
645
        mov     [ebx+dlgtemplate.border_size_y], eax
583
;  å®¤¨¬ è¨à¨­ã ¨ ¢ëá®âã ®ª­ 
646
;  å®¤¨¬ è¨à¨­ã ¨ ¢ëá®âã ®ª­ 
584
        xor     eax, eax
647
        xor     eax, eax
585
        xor     ecx, ecx
648
        xor     ecx, ecx
586
        mov     esi, [esp+20h+20]
649
        mov     esi, [esp+20h+20]
587
        mov     [ebx+36], esi
650
        mov     [ebx+40], esi
588
        and     dword [ebx+52], 0
651
        and     dword [ebx+56], 0
589
@@:
652
@@:
590
        cmp     dword [esi+4], 0
653
        cmp     dword [esi+4], 0
591
        jz      .find_width
654
        jz      .find_width
592
        mov     esi, [esi+4]
655
        mov     esi, [esi+4]
593
        inc     dword [ebx+52]
656
        inc     dword [ebx+56]
594
        jmp     @b
657
        jmp     @b
595
.find_width:
658
.find_width:
596
        mov     [ebx+44], esi
659
        mov     [ebx+48], esi
597
        add     esi, 8
660
        add     esi, 8
598
        push    esi
661
        push    esi
599
        xor     edx, edx
662
        xor     edx, edx
600
.fw1:
663
.fw1:
601
        cmp     byte [esi], '&'
664
        cmp     byte [esi], '&'
602
        jnz     @f
665
        jnz     @f
603
        mov     dl, 1
666
        mov     dl, 1
604
@@:
667
@@:
605
        inc     esi
668
        inc     esi
606
        cmp     byte [esi-1], 0
669
        cmp     byte [esi-1], 0
607
        jnz     .fw1
670
        jnz     .fw1
608
        sub     esi, [esp]
671
        sub     esi, [esp]
609
        sub     esi, edx
672
        sub     esi, edx
610
        dec     esi
673
        dec     esi
611
        cmp     eax, esi
674
        cmp     eax, esi
612
        ja      @f
675
        ja      @f
613
        mov     eax, esi
676
        mov     eax, esi
614
@@:
677
@@:
615
        inc     ecx
678
        inc     ecx
616
        pop     esi
679
        pop     esi
617
        mov     esi, [esi-8]
680
        mov     esi, [esi-8]
618
        test    esi, esi
681
        test    esi, esi
619
        jnz     .find_width
682
        jnz     .find_width
620
        add     eax, 3
683
        add     eax, 3
621
        add     eax, [ebx+dlgtemplate.border_size_x]
684
        add     eax, [ebx+dlgtemplate.border_size_x]
622
        add     eax, [ebx+dlgtemplate.border_size_x]
685
        add     eax, [ebx+dlgtemplate.border_size_x]
623
        cmp     eax, [cur_width]
686
        cmp     eax, [cur_width]
624
        jb      @f
687
        jb      @f
625
        mov     eax, [cur_width]
688
        mov     eax, [cur_width]
626
@@:
689
@@:
627
        sub     eax, [ebx+dlgtemplate.border_size_x]
690
        sub     eax, [ebx+dlgtemplate.border_size_x]
628
        sub     eax, [ebx+dlgtemplate.border_size_x]
691
        sub     eax, [ebx+dlgtemplate.border_size_x]
629
        mov     [ebx+dlgtemplate.width], eax
692
        mov     [ebx+dlgtemplate.width], eax
630
        mov     [ebx+dlgtemplate.height], ecx
693
        mov     [ebx+dlgtemplate.height], ecx
631
        mov     [ebx+40], ecx
694
        mov     [ebx+44], ecx
632
        sub     eax, [esp+20h+12]
695
        sub     eax, [esp+20h+12]
633
        neg     eax
696
        neg     eax
634
        sar     eax, 1
697
        sar     eax, 1
635
        add     eax, [esp+20h+4]
698
        add     eax, [esp+20h+4]
636
        cmp     eax, [ebx+dlgtemplate.border_size_x]
699
        cmp     eax, [ebx+dlgtemplate.border_size_x]
637
        jge     @f
700
        jge     @f
638
        mov     eax, [ebx+dlgtemplate.border_size_x]
701
        mov     eax, [ebx+dlgtemplate.border_size_x]
639
@@:
702
@@:
640
        push    eax
703
        push    eax
641
        add     eax, [ebx+dlgtemplate.width]
704
        add     eax, [ebx+dlgtemplate.width]
642
        add     eax, [ebx+dlgtemplate.border_size_x]
705
        add     eax, [ebx+dlgtemplate.border_size_x]
643
        cmp     eax, [cur_width]
706
        cmp     eax, [cur_width]
644
        jbe     @f
707
        jbe     @f
645
        pop     eax
708
        pop     eax
646
        mov     eax, [cur_width]
709
        mov     eax, [cur_width]
647
        sub     eax, [ebx+dlgtemplate.width]
710
        sub     eax, [ebx+dlgtemplate.width]
648
        sub     eax, [ebx+dlgtemplate.border_size_x]
711
        sub     eax, [ebx+dlgtemplate.border_size_x]
649
        push    eax
712
        push    eax
650
@@:
713
@@:
651
        pop     [ebx+dlgtemplate.x]
714
        pop     [ebx+dlgtemplate.x]
652
        sub     ecx, [esp+20h+16]
715
        sub     ecx, [esp+20h+16]
653
        neg     ecx
716
        neg     ecx
654
        sar     ecx, 1
717
        sar     ecx, 1
655
        add     ecx, [esp+20h+8]
718
        add     ecx, [esp+20h+8]
656
        cmp     ecx, [ebx+dlgtemplate.border_size_y]
719
        cmp     ecx, [ebx+dlgtemplate.border_size_y]
657
        jge     @f
720
        jge     @f
658
        mov     ecx, [ebx+dlgtemplate.border_size_y]
721
        mov     ecx, [ebx+dlgtemplate.border_size_y]
659
@@:
722
@@:
660
        push    ecx
723
        push    ecx
661
        add     ecx, [ebx+dlgtemplate.height]
724
        add     ecx, [ebx+dlgtemplate.height]
662
        add     ecx, [ebx+dlgtemplate.border_size_y]
725
        add     ecx, [ebx+dlgtemplate.border_size_y]
663
        cmp     ecx, [cur_height]
726
        cmp     ecx, [cur_height]
664
        jbe     @f
727
        jbe     @f
665
        pop     ecx
728
        pop     ecx
666
        mov     ecx, [cur_height]
729
        mov     ecx, [cur_height]
667
        sub     ecx, [ebx+dlgtemplate.height]
730
        sub     ecx, [ebx+dlgtemplate.height]
668
        sub     ecx, [ebx+dlgtemplate.border_size_y]
731
        sub     ecx, [ebx+dlgtemplate.border_size_y]
669
        push    ecx
732
        push    ecx
670
@@:
733
@@:
671
        pop     [ebx+dlgtemplate.y]
734
        pop     [ebx+dlgtemplate.y]
672
        mov     eax, [cur_height]
735
        mov     eax, [cur_height]
673
        sub     eax, 6
736
        sub     eax, 6
674
        cmp     [ebx+dlgtemplate.height], eax
737
        cmp     [ebx+dlgtemplate.height], eax
675
        jbe     .small_height
738
        jbe     .small_height
676
        mov     [ebx+dlgtemplate.height], eax
739
        mov     [ebx+dlgtemplate.height], eax
677
        mov     [ebx+dlgtemplate.y], 3
740
        mov     [ebx+dlgtemplate.y], 3
678
.small_height:
741
.small_height:
679
        mov     ecx, [ebx+dlgtemplate.height]
742
        mov     ecx, [ebx+dlgtemplate.height]
680
        mov     eax, [ebx+36]
743
        mov     eax, [ebx+40]
681
        mov     [ebx+44], eax
744
        mov     [ebx+48], eax
682
        dec     ecx
745
        dec     ecx
683
        jz      .skip
746
        jz      .skip
684
        push    ecx
747
        push    ecx
685
@@:
748
@@:
686
        cmp     dword [eax+4], 0
749
        cmp     dword [eax+4], 0
687
        jz      @f
750
        jz      @f
688
        mov     eax, [eax+4]
751
        mov     eax, [eax+4]
689
        loop    @b
752
        loop    @b
690
@@:
753
@@:
691
        mov     [ebx+44], eax
754
        mov     [ebx+48], eax
692
        pop     ecx
755
        pop     ecx
693
.loop:
756
.loop:
694
        mov     eax, [eax]
757
        mov     eax, [eax]
695
        loop    .loop
758
        loop    .loop
696
.skip:
759
.skip:
697
        mov     [ebx+48], eax
760
        mov     [ebx+52], eax
698
        mov     eax, [esp+20h+24]
761
        mov     eax, [esp+20h+24]
699
        mov     [ebx+dlgtemplate.title], eax
762
        mov     [ebx+dlgtemplate.title], eax
700
        mov     al, [menu_normal_color]
763
        mov     al, [menu_normal_color]
701
        mov     [ebx+dlgtemplate.main_color], al
764
        mov     [ebx+dlgtemplate.main_color], al
702
        mov     al, [menu_border_color]
765
        mov     al, [menu_border_color]
703
        mov     [ebx+dlgtemplate.border_color], al
766
        mov     [ebx+dlgtemplate.border_color], al
704
        mov     al, [menu_header_color]
767
        mov     al, [menu_header_color]
705
        mov     [ebx+dlgtemplate.header_color], al
768
        mov     [ebx+dlgtemplate.header_color], al
706
        push    MenuDlgProc
769
        push    MenuDlgProc
707
        push    ebx
770
        push    ebx
708
        call    GenericBox
771
        call    GenericBox
709
        mov     [esp+28], eax
772
        mov     [esp+28], eax
710
        mov     ecx, ebx
773
        mov     ecx, ebx
711
        call    pgfree
774
        call    pgfree
712
        popad
775
        popad
713
        ret     28
776
        ret     28
714
 
777
 
715
MenuDlgProc:
778
MenuDlgProc:
716
        mov     eax, [esp+8]
779
        mov     eax, [esp+8]
717
        cmp     al, 1
780
        cmp     al, 1
718
        jz      .draw
781
        jz      .draw
719
        cmp     al, 2
782
        cmp     al, 2
720
        jz      .key
783
        jz      .key
721
        ret     16
784
        ret     16
722
.draw:
785
.draw:
723
        call    .dodraw
786
        call    .dodraw
724
        ret     16
787
        ret     16
725
.prev:
788
.prev:
726
        mov     eax, [ebx+36]
789
        mov     eax, [ebx+40]
727
        cmp     dword [eax+4], 0
790
        cmp     dword [eax+4], 0
728
        jz      .end
791
        jz      .end
729
        call    .line_prev
792
        call    .line_prev
730
.posret:
793
.posret:
731
        mov     [ebx+36], eax
794
        mov     [ebx+40], eax
732
.redraw:
795
.redraw:
733
        call    .dodraw
796
        call    .dodraw
734
        call    draw_image
797
        call    draw_image
735
        xor     eax, eax
798
        xor     eax, eax
736
        ret     16
799
        ret     16
737
.next:
800
.next:
738
        mov     eax, [ebx+36]
801
        mov     eax, [ebx+40]
739
        cmp     dword [eax], 0
802
        cmp     dword [eax], 0
740
        jz      .home
803
        jz      .home
741
        call    .line_next
804
        call    .line_next
742
        jmp     .posret
805
        jmp     .posret
743
.pgdn:
806
.pgdn:
744
        mov     eax, [ebx+36]
807
        mov     eax, [ebx+40]
745
        mov     ecx, [ebx+dlgtemplate.height]
808
        mov     ecx, [ebx+dlgtemplate.height]
746
.pgdnl:
809
.pgdnl:
747
        cmp     dword [eax], 0
810
        cmp     dword [eax], 0
748
        jz      .posret
811
        jz      .posret
749
        call    .line_next
812
        call    .line_next
750
        loop    .pgdnl
813
        loop    .pgdnl
751
        jmp     .posret
814
        jmp     .posret
752
.key:
815
.key:
753
        mov     al, [esp+12]
816
        mov     al, [esp+12]
754
        cmp     al, 0x48
817
        cmp     al, 0x48
755
        jz      .prev
818
        jz      .prev
756
        cmp     al, 0x4B
819
        cmp     al, 0x4B
757
        jz      .prev
820
        jz      .prev
758
        cmp     al, 0x4D
821
        cmp     al, 0x4D
759
        jz      .next
822
        jz      .next
760
        cmp     al, 0x50
823
        cmp     al, 0x50
761
        jz      .next
824
        jz      .next
762
        cmp     al, 0x1C
825
        cmp     al, 0x1C
763
        jz      .enter
826
        jz      .enter
764
        cmp     al, 1
827
        cmp     al, 1
765
        jz      .esc
828
        jz      .esc
766
        cmp     al, 0x47
829
        cmp     al, 0x47
767
        jz      .home
830
        jz      .home
768
        cmp     al, 0x4F
831
        cmp     al, 0x4F
769
        jz      .end
832
        jz      .end
770
        cmp     al, 0x51
833
        cmp     al, 0x51
771
        jz      .pgdn
834
        jz      .pgdn
772
        cmp     al, 0x49
835
        cmp     al, 0x49
773
        jz      .pgup
836
        jz      .pgup
774
        cmp     al, 0x52
837
        cmp     al, 0x52
775
        jz      .ins
838
        jz      .ins
776
        cmp     al, 0x53
839
        cmp     al, 0x53
777
        jz      .del
840
        jz      .del
778
        mov     edx, [ebx+36]
841
        mov     edx, [ebx+40]
779
@@:
842
@@:
780
        cmp     dword [edx+4], 0
843
        cmp     dword [edx+4], 0
781
        jz      @f
844
        jz      @f
782
        mov     edx, [edx+4]
845
        mov     edx, [edx+4]
783
        jmp     @b
846
        jmp     @b
784
@@:
847
@@:
785
.l:
848
.l:
786
        lea     esi, [edx+7]
849
        lea     esi, [edx+7]
787
@@:
850
@@:
788
        inc     esi
851
        inc     esi
789
        cmp     byte [esi], 0
852
        cmp     byte [esi], 0
790
        jz      .n
853
        jz      .n
791
        cmp     byte [esi], '&'
854
        cmp     byte [esi], '&'
792
        jnz     @b
855
        jnz     @b
793
        movzx   ecx, byte [esi+1]
856
        movzx   ecx, byte [esi+1]
794
        cmp     [ascii2scan+ecx], al
857
        cmp     [ascii2scan+ecx], al
795
        jnz     .n
858
        jnz     .n
796
        mov     eax, edx
859
        mov     eax, edx
797
        ret     16
860
        ret     16
798
.n:
861
.n:
799
        mov     edx, [edx]
862
        mov     edx, [edx]
800
        test    edx, edx
863
        test    edx, edx
801
        jnz     .l
864
        jnz     .l
802
.ret:
865
.ret:
803
        xor     eax, eax
866
        xor     eax, eax
804
        ret     16
867
        ret     16
805
.pgup:
868
.pgup:
806
        mov     eax, [ebx+36]
869
        mov     eax, [ebx+40]
807
        mov     ecx, [ebx+dlgtemplate.height]
870
        mov     ecx, [ebx+dlgtemplate.height]
808
.pgupl:
871
.pgupl:
809
        cmp     dword [eax+4], 0
872
        cmp     dword [eax+4], 0
810
        jz      .posret
873
        jz      .posret
811
        call    .line_prev
874
        call    .line_prev
812
        loop    .pgupl
875
        loop    .pgupl
813
        jmp     .posret
876
        jmp     .posret
814
.home:
877
.home:
815
        mov     eax, [ebx+36]
878
        mov     eax, [ebx+40]
816
@@:
879
@@:
817
        cmp     dword [eax+4], 0
880
        cmp     dword [eax+4], 0
818
        jz      @f
881
        jz      @f
819
        mov     eax, [eax+4]
882
        mov     eax, [eax+4]
820
        jmp     @b
883
        jmp     @b
821
@@:
884
@@:
822
        mov     [ebx+44], eax
885
        mov     [ebx+48], eax
823
        push    eax
886
        push    eax
824
        mov     ecx, [ebx+dlgtemplate.height]
887
        mov     ecx, [ebx+dlgtemplate.height]
825
        dec     ecx
888
        dec     ecx
826
        jz      .h1
889
        jz      .h1
827
.h2:
890
.h2:
828
        mov     eax, [eax]
891
        mov     eax, [eax]
829
        loop    .h2
892
        loop    .h2
830
.h1:
893
.h1:
831
        mov     [ebx+48], eax
894
        mov     [ebx+52], eax
832
        pop     eax
895
        pop     eax
833
        and     dword [ebx+52], 0
896
        and     dword [ebx+56], 0
834
        jmp     .posret
897
        jmp     .posret
835
.end:
898
.end:
836
        mov     eax, [ebx+36]
899
        mov     eax, [ebx+40]
837
@@:
900
@@:
838
        cmp     dword [eax], 0
901
        cmp     dword [eax], 0
839
        jz      @f
902
        jz      @f
840
        mov     eax, [eax]
903
        mov     eax, [eax]
841
        jmp     @b
904
        jmp     @b
842
@@:
905
@@:
843
        mov     [ebx+48], eax
906
        mov     [ebx+52], eax
844
        push    eax
907
        push    eax
845
        mov     ecx, [ebx+dlgtemplate.height]
908
        mov     ecx, [ebx+dlgtemplate.height]
846
        dec     ecx
909
        dec     ecx
847
        jz      .e1
910
        jz      .e1
848
.e2:
911
.e2:
849
        mov     eax, [eax+4]
912
        mov     eax, [eax+4]
850
        loop    .e2
913
        loop    .e2
851
.e1:
914
.e1:
852
        mov     [ebx+44], eax
915
        mov     [ebx+48], eax
853
        mov     eax, [ebx+40]
916
        mov     eax, [ebx+44]
854
        dec     eax
917
        dec     eax
855
        mov     [ebx+52], eax
918
        mov     [ebx+56], eax
856
        pop     eax
919
        pop     eax
857
        jmp     .posret
920
        jmp     .posret
858
.esc:
921
.esc:
859
        or      eax, -1
922
        or      eax, -1
860
        ret     16
923
        ret     16
861
.enter:
924
.enter:
862
        mov     eax, [ebx+36]
925
        mov     eax, [ebx+40]
863
        ret     16
926
        ret     16
864
.ins:
927
.ins:
865
        push    5
928
        push    5
866
        pop     edx
929
        pop     edx
867
        jmp     @f
930
        jmp     @f
868
.del:
931
.del:
869
        push    4
932
        push    4
870
        pop     edx
933
        pop     edx
871
@@:
934
@@:
872
        mov     eax, [ebx+36]
935
        mov     eax, [ebx+40]
873
        cmp     byte [eax+8], '/'
936
        cmp     byte [eax+8], '/'
874
        jnz     @f
937
        jnz     @f
875
        cmp     word [eax+9], 'cd'
938
        cmp     word [eax+9], 'cd'
876
        jnz     @f
939
        jnz     @f
877
        movzx   ecx, byte [eax+11]
940
        movzx   ecx, byte [eax+11]
878
        sub     ecx, '0'
941
        sub     ecx, '0'
879
        push    24
942
        push    24
880
        pop     eax
943
        pop     eax
881
        mov     ebx, edx
944
        mov     ebx, edx
882
        int     40h
945
        int     40h
883
@@:
946
@@:
884
        xor     eax, eax
947
        xor     eax, eax
885
        ret     16
948
        ret     16
886
 
949
 
887
.line_prev:
950
.line_prev:
888
        cmp     eax, [ebx+44]
951
        cmp     eax, [ebx+48]
889
        jnz     @f
952
        jnz     @f
890
        mov     edx, [ebx+44]
-
 
891
        mov     edx, [edx+4]
-
 
892
        mov     [ebx+44], edx
-
 
893
        mov     edx, [ebx+48]
953
        mov     edx, [ebx+48]
894
        mov     edx, [edx+4]
954
        mov     edx, [edx+4]
895
        mov     [ebx+48], edx
955
        mov     [ebx+48], edx
-
 
956
        mov     edx, [ebx+52]
-
 
957
        mov     edx, [edx+4]
-
 
958
        mov     [ebx+52], edx
896
@@:
959
@@:
897
        mov     eax, [eax+4]
960
        mov     eax, [eax+4]
898
        dec     dword [ebx+52]
961
        dec     dword [ebx+56]
899
        ret
962
        ret
900
.line_next:
963
.line_next:
901
        cmp     eax, [ebx+48]
964
        cmp     eax, [ebx+52]
902
        jnz     @f
965
        jnz     @f
903
        mov     edx, [ebx+44]
-
 
904
        mov     edx, [edx]
-
 
905
        mov     [ebx+44], edx
-
 
906
        mov     edx, [ebx+48]
966
        mov     edx, [ebx+48]
907
        mov     edx, [edx]
967
        mov     edx, [edx]
908
        mov     [ebx+48], edx
968
        mov     [ebx+48], edx
-
 
969
        mov     edx, [ebx+52]
-
 
970
        mov     edx, [edx]
-
 
971
        mov     [ebx+52], edx
909
@@:
972
@@:
910
        mov     eax, [eax]
973
        mov     eax, [eax]
911
        inc     dword [ebx+52]
974
        inc     dword [ebx+56]
912
        ret
975
        ret
913
 
976
 
914
.dodraw:
977
.dodraw:
915
        mov     eax, [ebx+dlgtemplate.x]
978
        mov     eax, [ebx+dlgtemplate.x]
916
        mov     edx, [ebx+dlgtemplate.y]
979
        mov     edx, [ebx+dlgtemplate.y]
917
        call    get_console_ptr
980
        call    get_console_ptr
918
        mov     esi, [ebx+44]
981
        mov     esi, [ebx+48]
919
.0:
982
.0:
920
        xor     edx, edx
983
        xor     edx, edx
921
        mov     ah, [menu_selected_color]
984
        mov     ah, [menu_selected_color]
922
        cmp     esi, [ebx+36]
985
        cmp     esi, [ebx+40]
923
        jz      @f
986
        jz      @f
924
        mov     ah, [menu_normal_color]
987
        mov     ah, [menu_normal_color]
925
@@:
988
@@:
926
        push    edi
989
        push    edi
927
        mov     ecx, [ebx+dlgtemplate.width]
990
        mov     ecx, [ebx+dlgtemplate.width]
928
        mov     al, ' '
991
        mov     al, ' '
929
        stosw
992
        stosw
930
        dec     ecx
993
        dec     ecx
931
        stosw
994
        stosw
932
        dec     ecx
995
        dec     ecx
933
        dec     ecx
996
        dec     ecx
934
        push    esi
997
        push    esi
935
        add     esi, 8
998
        add     esi, 8
936
@@:
999
@@:
937
        lodsb
1000
        lodsb
938
        test    al, al
1001
        test    al, al
939
        jz      @f
1002
        jz      @f
940
        cmp     al, '&'
1003
        cmp     al, '&'
941
        jnz     .noamp
1004
        jnz     .noamp
942
        test    dl, dl
1005
        test    dl, dl
943
        jnz     .noamp
1006
        jnz     .noamp
944
        mov     dl, 1
1007
        mov     dl, 1
945
        lodsb
1008
        lodsb
946
        push    eax
1009
        push    eax
947
        mov     ah, [menu_selected_highlight_color]
1010
        mov     ah, [menu_selected_highlight_color]
948
        push    ecx
1011
        push    ecx
949
        mov     ecx, [esp+8]
1012
        mov     ecx, [esp+8]
950
        cmp     ecx, [ebx+36]
1013
        cmp     ecx, [ebx+40]
951
        pop     ecx
1014
        pop     ecx
952
        jz      .amp1
1015
        jz      .amp1
953
        mov     ah, [menu_highlight_color]
1016
        mov     ah, [menu_highlight_color]
954
.amp1:
1017
.amp1:
955
        stosw
1018
        stosw
956
        pop     eax
1019
        pop     eax
957
        jmp     .amp2
1020
        jmp     .amp2
958
.noamp:
1021
.noamp:
959
        stosw
1022
        stosw
960
.amp2:
1023
.amp2:
961
        loop    @b
1024
        loop    @b
962
        mov     al, ' '
1025
        mov     al, ' '
963
        cmp     byte [esi], 0
1026
        cmp     byte [esi], 0
964
        jnz     .1
1027
        jnz     .1
965
        lodsb
1028
        lodsb
966
        jmp     .1
1029
        jmp     .1
967
@@:
1030
@@:
968
        mov     al, ' '
1031
        mov     al, ' '
969
.1:
1032
.1:
970
        stosw
1033
        stosw
971
        mov     al, ' '
1034
        mov     al, ' '
972
        rep     stosw
1035
        rep     stosw
973
        pop     esi edi
1036
        pop     esi edi
974
        add     edi, [cur_width]
1037
        add     edi, [cur_width]
975
        add     edi, [cur_width]
1038
        add     edi, [cur_width]
976
        cmp     esi, [ebx+48]
1039
        cmp     esi, [ebx+52]
977
        jz      @f
1040
        jz      @f
978
        mov     esi, [esi]
1041
        mov     esi, [esi]
979
        test    esi, esi
1042
        test    esi, esi
980
        jnz     .0
1043
        jnz     .0
981
@@:
1044
@@:
982
; ‹¨­¥©ª  ¯à®ªàã⪨
1045
; ‹¨­¥©ª  ¯à®ªàã⪨
983
        mov     ecx, [ebx+dlgtemplate.height]
1046
        mov     ecx, [ebx+dlgtemplate.height]
984
        cmp     ecx, [ebx+40]
1047
        cmp     ecx, [ebx+44]
985
        jz      .noscrollbar
1048
        jz      .noscrollbar
986
        sub     ecx, 2
1049
        sub     ecx, 2
987
        jbe     .noscrollbar
1050
        jbe     .noscrollbar
988
        mov     eax, [ebx+52]
1051
        mov     eax, [ebx+56]
989
        mul     ecx
1052
        mul     ecx
990
        div     dword [ebx+40]
1053
        div     dword [ebx+44]
991
        push    eax
1054
        push    eax
992
        mov     eax, [ebx+dlgtemplate.x]
1055
        mov     eax, [ebx+dlgtemplate.x]
993
        add     eax, [ebx+dlgtemplate.width]
1056
        add     eax, [ebx+dlgtemplate.width]
994
        mov     edx, [ebx+dlgtemplate.y]
1057
        mov     edx, [ebx+dlgtemplate.y]
995
        call    get_console_ptr
1058
        call    get_console_ptr
996
        pop     edx
1059
        pop     edx
997
        inc     edx
1060
        inc     edx
998
        mov     al, 0x1E
1061
        mov     al, 0x1E
999
        mov     ah, [menu_scrollbar_color]
1062
        mov     ah, [menu_scrollbar_color]
1000
        mov     [edi], ax
1063
        mov     [edi], ax
1001
        add     edi, [cur_width]
1064
        add     edi, [cur_width]
1002
        add     edi, [cur_width]
1065
        add     edi, [cur_width]
1003
.2:
1066
.2:
1004
        mov     al, 0xB2
1067
        mov     al, 0xB2
1005
        dec     edx
1068
        dec     edx
1006
        jz      @f
1069
        jz      @f
1007
        mov     al, 0xB0
1070
        mov     al, 0xB0
1008
@@:
1071
@@:
1009
        mov     [edi], ax
1072
        mov     [edi], ax
1010
        add     edi, [cur_width]
1073
        add     edi, [cur_width]
1011
        add     edi, [cur_width]
1074
        add     edi, [cur_width]
1012
        loop    .2
1075
        loop    .2
1013
        mov     al, 0x1F
1076
        mov     al, 0x1F
1014
        stosw
1077
        stosw
1015
.noscrollbar:
1078
.noscrollbar:
1016
        ret
1079
        ret
-
 
1080
 
-
 
1081
get_ascii_char:
-
 
1082
; query keyboard layout
-
 
1083
        pushad
-
 
1084
        mov     al, [ctrlstate]
-
 
1085
        and     al, 3
-
 
1086
        xor     ecx, ecx
-
 
1087
        cmp     al, 1
-
 
1088
        sbb     ecx, -2
-
 
1089
        push    26
-
 
1090
        pop     eax
-
 
1091
        push    2
-
 
1092
        pop     ebx
-
 
1093
        mov     edx, layout
-
 
1094
        int     0x40
-
 
1095
        popad
-
 
1096
; translate scancode to ASCII
-
 
1097
        movzx   eax, byte [layout+eax]
-
 
1098
        ret
1017
 
1099
 
1018
virtual at 0
1100
virtual at 0
1019
dlgitemtemplate:
1101
dlgitemtemplate:
1020
; «¥¬¥­âë:
1102
; «¥¬¥­âë:
1021
;       1 = áâ â¨ç¥áª¨© ⥪áâ
1103
;       1 = áâ â¨ç¥áª¨© ⥪áâ
1022
;       2 = ª­®¯ª 
1104
;       2 = ª­®¯ª 
1023
;       3 = ¯®«¥ । ªâ¨à®¢ ­¨ï
1105
;       3 = ¯®«¥ । ªâ¨à®¢ ­¨ï
1024
.type           dd      ?
1106
.type           dd      ?
1025
.x1             dd      ?
1107
.x1             dd      ?
1026
.y1             dd      ?
1108
.y1             dd      ?
1027
.x2             dd      ?
1109
.x2             dd      ?
1028
.y2             dd      ?
1110
.y2             dd      ?
1029
; „ ­­ë¥:
1111
; „ ­­ë¥:
1030
; ¤«ï ⥪áâ : const char* data - ASCIIZ-áâப 
1112
; ¤«ï ⥪áâ : const char* data - ASCIIZ-áâப 
1031
; ¤«ï ª­®¯ª¨: const char* data - § £®«®¢®ª
1113
; ¤«ï ª­®¯ª¨: const char* data - § £®«®¢®ª
1032
; ¤«ï । ªâ®à : struct {unsigned maxlength; unsigned pos; unsigned start;
1114
; ¤«ï । ªâ®à : struct {unsigned maxlength; unsigned pos; unsigned start;
1033
;                        char data[maxlength+1];}* data;
1115
;                        char data[maxlength+1];}* data;
1034
.data           dd      ?
1116
.data           dd      ?
1035
.flags          dd      ?
1117
.flags          dd      ?
1036
; ”« £¨:
1118
; ”« £¨:
1037
;       0 = ¢ëà ¢­¨¢ ­¨¥ ¢«¥¢®
1119
;       0 = ¢ëà ¢­¨¢ ­¨¥ ¢«¥¢®
1038
;       1 = ¢ëà ¢­¨¢ ­¨¥ ¯® 業âàã
1120
;       1 = ¢ëà ¢­¨¢ ­¨¥ ¯® 業âàã
1039
;       2 = ¢ëà ¢­¨¢ ­¨¥ ¢¯à ¢®
1121
;       2 = ¢ëà ¢­¨¢ ­¨¥ ¢¯à ¢®
1040
;       4 = í«¥¬¥­â ¨¬¥¥â 䮪ãá ¢¢®¤ 
1122
;       4 = í«¥¬¥­â ¨¬¥¥â 䮪ãá ¢¢®¤ 
1041
;       8 = í«¥¬¥­â ¬®¦¥â ¨¬¥âì 䮪ãá ¢¢®¤ 
1123
;       8 = í«¥¬¥­â ¬®¦¥â ¨¬¥âì 䮪ãá ¢¢®¤ 
1042
;       10h: ¤«ï ª­®¯ª¨ = ª­®¯ª  ¯® 㬮«ç ­¨î (Enter ­  ­¥-ª­®¯ª¥)
1124
;       10h: ¤«ï ª­®¯ª¨ = ª­®¯ª  ¯® 㬮«ç ­¨î (Enter ­  ­¥-ª­®¯ª¥)
1043
;            ¤«ï ¯®«ï ¢¢®¤  = ¤ ­­ë¥ ¡ë«¨ ¬®¤¨ä¨æ¨à®¢ ­ë
1125
;            ¤«ï ¯®«ï ¢¢®¤  = ¤ ­­ë¥ ¡ë«¨ ¬®¤¨ä¨æ¨à®¢ ­ë
1044
;       20h: ¤«ï ¯®«ï ¢¢®¤  = ­¥ ®â®¡à ¦ âì ¢¢®¤¨¬ë¥ ¤ ­­ë¥ (¯®ª §ë¢ âì '*')
1126
;       20h: ¤«ï ¯®«ï ¢¢®¤  = ­¥ ®â®¡à ¦ âì ¢¢®¤¨¬ë¥ ¤ ­­ë¥ (¯®ª §ë¢ âì '*')
1045
.size = $
1127
.size = $
1046
end virtual
1128
end virtual
1047
;       struct DLGDATA
1129
;       struct DLGDATA
1048
;       {
1130
;       {
1049
;               DLGTEMPLATE dialog;     /* window description */
1131
;               DLGTEMPLATE dialog;     /* window description */
1050
;               void* DlgProc;          /* dialog procedure */
1132
;               void* DlgProc;          /* dialog procedure */
1051
; /* int __stdcall DlgProc(DLGDATA* dlg, int msg, int param1, int param2); */
1133
; /* int __stdcall DlgProc(DLGDATA* dlg, int msg, int param1, int param2); */
1052
;               void* user_data;        /* arbitrary user data */
1134
;               void* user_data;        /* arbitrary user data */
1053
;               unsigned num_items;     /* number of items in the following array */
1135
;               unsigned num_items;     /* number of items in the following array */
1054
;               DLGITEMTEMPLATE items[]; /* array of dialog items */
1136
;               DLGITEMTEMPLATE items[]; /* array of dialog items */
1055
;       }
1137
;       }
1056
; int __stdcall DialogBox(DLGDATA* dlg);
1138
; int __stdcall DialogBox(DLGDATA* dlg);
1057
DialogBox:
1139
DialogBox:
1058
        push    ManagerDlgProc
1140
        push    ManagerDlgProc
1059
        push    dword [esp+8]
1141
        push    dword [esp+8]
1060
        call    GenericBox
1142
        call    GenericBox
1061
        ret     4
1143
        ret     4
-
 
1144
 
-
 
1145
; int __stdcall ShowDialogBox(DLGDATA* dlg);
-
 
1146
ShowDialogBox:
-
 
1147
        push    ManagerDlgProc
-
 
1148
        push    dword [esp+8]
-
 
1149
        call    ShowGenericBox
-
 
1150
        ret     4
-
 
1151
 
-
 
1152
; void __stdcall DrawDialogBox(DLGDATA* dlg);
-
 
1153
DrawDialogBox:
-
 
1154
        push    ManagerDlgProc
-
 
1155
        push    dword [esp+8]
-
 
1156
        call    DrawGenericBox
-
 
1157
        ret     4
1062
 
1158
 
1063
ManagerDlgProc:
1159
ManagerDlgProc:
1064
        mov     ebp, ebx
1160
        mov     ebp, ebx
1065
        mov     eax, [esp+8]
1161
        mov     eax, [esp+8]
1066
        dec     eax
1162
        dec     eax
1067
        jz      .draw
1163
        jz      .draw
1068
        dec     eax
1164
        dec     eax
1069
        jz      .key
1165
        jz      .key
1070
        xor     eax, eax
1166
        xor     eax, eax
1071
        ret     16
1167
        ret     16
1072
.draw:
1168
.draw:
1073
        call    .dodraw
1169
        call    .dodraw
1074
        ret     16
1170
        ret     16
1075
.key:
1171
.key:
1076
; find item with focus
1172
; find item with focus
1077
        add     ebx, dlgtemplate.size+12
1173
        add     ebx, dlgtemplate.size+12
1078
        mov     ecx, [ebx-4]
1174
        mov     ecx, [ebx-4]
1079
        jecxz   .nobtns
1175
        jecxz   .nobtns
1080
@@:
1176
@@:
1081
        test    [ebx+dlgitemtemplate.flags], 4
1177
        test    [ebx+dlgitemtemplate.flags], 4
1082
        jnz     @f
1178
        jnz     @f
1083
        add     ebx, dlgitemtemplate.size
1179
        add     ebx, dlgitemtemplate.size
1084
        loop    @b
1180
        loop    @b
1085
@@:
1181
@@:
1086
.nobtns:
1182
.nobtns:
1087
        mov     al, [esp+12]
1183
        mov     al, [esp+12]
1088
        cmp     al, 1
1184
        cmp     al, 1
1089
        jz      .esc
1185
        jz      .esc
1090
        cmp     al, 0x1C
1186
        cmp     al, 0x1C
1091
        jz      .enter
1187
        jz      .enter
1092
        cmp     al, 0xF
1188
        cmp     al, 0xF
1093
        jz      .tab
1189
        jz      .tab
1094
        cmp     al, 0x48
1190
        cmp     al, 0x48
1095
        jz      .up
1191
        jz      .up
1096
        cmp     al, 0x50
1192
        cmp     al, 0x50
1097
        jz      .down
1193
        jz      .down
1098
        jecxz   @f
1194
        jecxz   @f
1099
        cmp     [ebx+dlgitemtemplate.type], 3
1195
        cmp     [ebx+dlgitemtemplate.type], 3
1100
        jz      .key_edit
1196
        jz      .key_edit
1101
@@:
1197
@@:
1102
        cmp     al, 0x4B
1198
        cmp     al, 0x4B
1103
        jz      .left
1199
        jz      .left
1104
        cmp     al, 0x4D
1200
        cmp     al, 0x4D
1105
        jz      .right
1201
        jz      .right
1106
.ret0:
1202
.ret0:
1107
        xor     eax, eax
1203
        xor     eax, eax
1108
        ret     16
1204
        ret     16
1109
.esc:
1205
.esc:
1110
        or      eax, -1
1206
        or      eax, -1
1111
        ret     16
1207
        ret     16
1112
.enter:
1208
.enter:
1113
        cmp     [ebx+dlgitemtemplate.type], 2
1209
        cmp     [ebx+dlgitemtemplate.type], 2
1114
        jnz     @f
1210
        jnz     @f
1115
.enter_found:
1211
.enter_found:
1116
        mov     eax, ebx
1212
        mov     eax, ebx
1117
        ret     16
1213
        ret     16
1118
@@:
1214
@@:
1119
        lea     ebx, [ebp+dlgtemplate.size+12]
1215
        lea     ebx, [ebp+dlgtemplate.size+12]
1120
        mov     ecx, [ebx-4]
1216
        mov     ecx, [ebx-4]
1121
.enter_find:
1217
.enter_find:
1122
        cmp     [ebx+dlgitemtemplate.type], 2
1218
        cmp     [ebx+dlgitemtemplate.type], 2
1123
        jnz     @f
1219
        jnz     @f
1124
        test    [ebx+dlgitemtemplate.flags], 0x10
1220
        test    [ebx+dlgitemtemplate.flags], 0x10
1125
        jnz     .enter_found
1221
        jnz     .enter_found
1126
@@:
1222
@@:
1127
        add     ebx, dlgitemtemplate.size
1223
        add     ebx, dlgitemtemplate.size
1128
        loop    .enter_find
1224
        loop    .enter_find
1129
        jmp     .enter_found
1225
        jmp     .enter_found
1130
.tab:
1226
.tab:
1131
        test    [ctrlstate], 3
1227
        test    [ctrlstate], 3
1132
        jnz     .shift_tab
1228
        jnz     .shift_tab
1133
.right:
1229
.right:
1134
.down:
1230
.down:
1135
        jecxz   .ret0
1231
        jecxz   .ret0
1136
        and     byte [ebx+dlgitemtemplate.flags], not 4
1232
        and     byte [ebx+dlgitemtemplate.flags], not 4
1137
        dec     ecx
1233
        dec     ecx
1138
        jz      .find_first_btn
1234
        jz      .find_first_btn
1139
@@:
1235
@@:
1140
        add     ebx, dlgitemtemplate.size
1236
        add     ebx, dlgitemtemplate.size
1141
        test    [ebx+dlgitemtemplate.flags], 8
1237
        test    [ebx+dlgitemtemplate.flags], 8
1142
        jnz     .btn_found
1238
        jnz     .btn_found
1143
        loop    @b
1239
        loop    @b
1144
.find_first_btn:
1240
.find_first_btn:
1145
        lea     ebx, [ebp+dlgtemplate.size+12]
1241
        lea     ebx, [ebp+dlgtemplate.size+12]
1146
@@:
1242
@@:
1147
        test    [ebx+dlgitemtemplate.flags], 8
1243
        test    [ebx+dlgitemtemplate.flags], 8
1148
        jnz     .btn_found
1244
        jnz     .btn_found
1149
        add     ebx, dlgitemtemplate.size
1245
        add     ebx, dlgitemtemplate.size
1150
        jmp     @b
1246
        jmp     @b
1151
.btn_found:
1247
.btn_found:
1152
        or      byte [ebx+dlgitemtemplate.flags], 4
1248
        or      byte [ebx+dlgitemtemplate.flags], 4
1153
.ret_draw:
1249
.ret_draw:
1154
        mov     ebx, ebp
1250
        mov     ebx, ebp
1155
        call    .dodraw
1251
        call    .dodraw
1156
        call    draw_image
1252
        call    draw_image
1157
        xor     eax, eax
1253
        xor     eax, eax
1158
        ret     16
1254
        ret     16
1159
.shift_tab:
1255
.shift_tab:
1160
.left:
1256
.left:
1161
.up:
1257
.up:
1162
        jecxz   .ret0
1258
        jecxz   .ret0
1163
        and     byte [ebx+dlgitemtemplate.flags], not 4
1259
        and     byte [ebx+dlgitemtemplate.flags], not 4
1164
        sub     ecx, [ebp+dlgtemplate.size+8]
1260
        sub     ecx, [ebp+dlgtemplate.size+8]
1165
        neg     ecx
1261
        neg     ecx
1166
        jz      .find_last_btn
1262
        jz      .find_last_btn
1167
@@:
1263
@@:
1168
        sub     ebx, dlgitemtemplate.size
1264
        sub     ebx, dlgitemtemplate.size
1169
        test    [ebx+dlgitemtemplate.flags], 8
1265
        test    [ebx+dlgitemtemplate.flags], 8
1170
        loopz   @b
1266
        loopz   @b
1171
        jnz     .btn_found
1267
        jnz     .btn_found
1172
.find_last_btn:
1268
.find_last_btn:
1173
        mov     ebx, [ebp+dlgtemplate.size+8]
1269
        mov     ebx, [ebp+dlgtemplate.size+8]
1174
        imul    ebx, dlgitemtemplate.size
1270
        imul    ebx, dlgitemtemplate.size
1175
        lea     ebx, [ebx+ebp+dlgtemplate.size+12]
1271
        lea     ebx, [ebx+ebp+dlgtemplate.size+12]
1176
@@:
1272
@@:
1177
        sub     ebx, dlgitemtemplate.size
1273
        sub     ebx, dlgitemtemplate.size
1178
        test    [ebx+dlgitemtemplate.flags], 8
1274
        test    [ebx+dlgitemtemplate.flags], 8
1179
        jz      @b
1275
        jz      @b
1180
        jmp     .btn_found
1276
        jmp     .btn_found
1181
.key_edit:
1277
.key_edit:
1182
; ®¡à ¡®âª  ª« ¢¨è ¢ ¯®«¥ ¢¢®¤ 
1278
; ®¡à ¡®âª  ª« ¢¨è ¢ ¯®«¥ ¢¢®¤ 
1183
        test    al, 0x80
1279
        test    al, 0x80
1184
        jnz     .ret0
1280
        jnz     .ret0
1185
        or      [ebx+dlgitemtemplate.flags], 0x10
1281
        or      [ebx+dlgitemtemplate.flags], 0x10
1186
        mov     edx, [ebx+dlgitemtemplate.data]
1282
        mov     edx, [ebx+dlgitemtemplate.data]
1187
        cmp     al, 0x4B
1283
        cmp     al, 0x4B
1188
        jz      .editor_left
1284
        jz      .editor_left
1189
        cmp     al, 0x4D
1285
        cmp     al, 0x4D
1190
        jz      .editor_right
1286
        jz      .editor_right
1191
        cmp     al, 0x47
1287
        cmp     al, 0x47
1192
        jz      .editor_home
1288
        jz      .editor_home
1193
        cmp     al, 0x4F
1289
        cmp     al, 0x4F
1194
        jz      .editor_end
1290
        jz      .editor_end
1195
        cmp     al, 0x0E
1291
        cmp     al, 0x0E
1196
        jz      .editor_backspace
1292
        jz      .editor_backspace
1197
        cmp     al, 0x53
1293
        cmp     al, 0x53
1198
        jnz     .editor_char
1294
        jnz     .editor_char
1199
.editor_del:
1295
.editor_del:
1200
        mov     ecx, [edx+4]
1296
        mov     ecx, [edx+4]
1201
        lea     edi, [ecx+edx+12]
1297
        lea     edi, [ecx+edx+12]
1202
        lea     esi, [edi+1]
1298
        lea     esi, [edi+1]
1203
        cmp     byte [edi], 0
1299
        cmp     byte [edi], 0
1204
        jz      .ret_test
1300
        jz      .ret_test
1205
        jmp     .copy_and_ret_test
1301
        jmp     .copy_and_ret_test
1206
.editor_left:
1302
.editor_left:
1207
        mov     ecx, [edx+4]
1303
        mov     ecx, [edx+4]
1208
        jecxz   @f
1304
        jecxz   @f
1209
        dec     dword [edx+4]
1305
        dec     dword [edx+4]
1210
@@:     jmp     .ret_test
1306
@@:     jmp     .ret_test
1211
.editor_right:
1307
.editor_right:
1212
        mov     ecx, [edx+4]
1308
        mov     ecx, [edx+4]
1213
        cmp     byte [edx+ecx+12], 0
1309
        cmp     byte [edx+ecx+12], 0
1214
        jz      @b
1310
        jz      @b
1215
        inc     dword [edx+4]
1311
        inc     dword [edx+4]
1216
        jmp     @b
1312
        jmp     @b
1217
.editor_home:
1313
.editor_home:
1218
        and     dword [edx+4], 0
1314
        and     dword [edx+4], 0
1219
        jmp     @b
1315
        jmp     @b
1220
.editor_end:
1316
.editor_end:
1221
        lea     edi, [edx+12]
1317
        lea     edi, [edx+12]
1222
        xor     eax, eax
1318
        xor     eax, eax
1223
        or      ecx, -1
1319
        or      ecx, -1
1224
        repnz   scasb
1320
        repnz   scasb
1225
        not     ecx
1321
        not     ecx
1226
        dec     ecx
1322
        dec     ecx
1227
        mov     [edx+4], ecx
1323
        mov     [edx+4], ecx
1228
.ret_test:
1324
.ret_test:
1229
        mov     eax, [edx+4]
1325
        mov     eax, [edx+4]
1230
        cmp     [edx+8], eax
1326
        cmp     [edx+8], eax
1231
        jl      .ret_test.l1
1327
        jl      .ret_test.l1
1232
        mov     [edx+8], eax
1328
        mov     [edx+8], eax
1233
        jmp     .ret_test.l2
1329
        jmp     .ret_test.l2
1234
.ret_test.l1:
1330
.ret_test.l1:
1235
        add     eax, [ebx+dlgitemtemplate.x1]
1331
        add     eax, [ebx+dlgitemtemplate.x1]
1236
        sub     eax, [ebx+dlgitemtemplate.x2]
1332
        sub     eax, [ebx+dlgitemtemplate.x2]
1237
        cmp     [edx+8], eax
1333
        cmp     [edx+8], eax
1238
        jge     .ret_test.l2
1334
        jge     .ret_test.l2
1239
        mov     [edx+8], eax
1335
        mov     [edx+8], eax
1240
.ret_test.l2:
1336
.ret_test.l2:
1241
        jmp     .ret_draw
1337
        jmp     .ret_draw
1242
.editor_backspace:
1338
.editor_backspace:
1243
        mov     ecx, [edx+4]
1339
        mov     ecx, [edx+4]
1244
        jecxz   .ret_test
1340
        jecxz   .ret_test
1245
        dec     dword [edx+4]
1341
        dec     dword [edx+4]
1246
        lea     esi, [edx+ecx+12]
1342
        lea     esi, [edx+ecx+12]
1247
        lea     edi, [esi-1]
1343
        lea     edi, [esi-1]
1248
.copy_and_ret_test:
1344
.copy_and_ret_test:
1249
@@:
1345
@@:
1250
        lodsb
1346
        lodsb
1251
        stosb
1347
        stosb
1252
        test    al, al
1348
        test    al, al
1253
        jnz     @b
1349
        jnz     @b
1254
        jmp     .ret_test
1350
        jmp     .ret_test
1255
.editor_char:
1351
.editor_char:
1256
        test    [ctrlstate], 0x3C
1352
        test    [ctrlstate], 0x3C
1257
        jnz     .ret_draw
1353
        jnz     .ret_draw
1258
; query keyboard layout
-
 
1259
        pushad
-
 
1260
        push    26
-
 
1261
        pop     eax
-
 
1262
        push    2
-
 
1263
        pop     ebx
-
 
1264
        xor     ecx, ecx
-
 
1265
        cmp     [ctrlstate], 1
-
 
1266
        sbb     ecx, -2
-
 
1267
        mov     edx, layout
-
 
1268
        int     0x40
-
 
1269
        popad
-
 
1270
; translate scancode to ASCII
-
 
1271
        movzx   eax, al
1354
        movzx   eax, al
1272
        movzx   eax, byte [layout+eax]
1355
        call    get_ascii_char
1273
        push    eax
1356
        push    eax
1274
; insert entered symbol
1357
; insert entered symbol
1275
        xor     eax, eax
1358
        xor     eax, eax
1276
        lea     edi, [edx+12]
1359
        lea     edi, [edx+12]
1277
        or      ecx, -1
1360
        or      ecx, -1
1278
        repnz   scasb
1361
        repnz   scasb
1279
        not     ecx
1362
        not     ecx
1280
        pop     eax
1363
        pop     eax
1281
        cmp     ecx, [edx]
1364
        cmp     ecx, [edx]
1282
        ja      .ret_test       ; buffer capacity exceeded
1365
        ja      .ret_test       ; buffer capacity exceeded
1283
        lea     edi, [edx+ecx+12-1]
1366
        lea     edi, [edx+ecx+12-1]
1284
        mov     esi, [edx+4]
1367
        mov     esi, [edx+4]
1285
        lea     esi, [edx+esi+12]
1368
        lea     esi, [edx+esi+12]
1286
@@:
1369
@@:
1287
        mov     cl, [edi]
1370
        mov     cl, [edi]
1288
        mov     [edi+1], cl
1371
        mov     [edi+1], cl
1289
        dec     edi
1372
        dec     edi
1290
        cmp     edi, esi
1373
        cmp     edi, esi
1291
        jae     @b
1374
        jae     @b
1292
        mov     [esi], al
1375
        mov     [esi], al
1293
        inc     dword [edx+4]
1376
        inc     dword [edx+4]
1294
@@:     jmp     .ret_test
1377
@@:     jmp     .ret_test
1295
 
1378
 
1296
.dodraw:
1379
.dodraw:
1297
        or      [cursor_x], -1
1380
        or      [cursor_x], -1
1298
        or      [cursor_y], -1
1381
        or      [cursor_y], -1
1299
        add     ebx, dlgtemplate.size+8
1382
        add     ebx, dlgtemplate.size+8
1300
        mov     ecx, [ebx]
1383
        mov     ecx, [ebx]
1301
        add     ebx, 4
1384
        add     ebx, 4
1302
        jecxz   .done_draw
1385
        jecxz   .done_draw
1303
.draw_loop:
1386
.draw_loop:
1304
        push    ecx
1387
        push    ecx
1305
        mov     eax, [ebx+dlgitemtemplate.type]
1388
        mov     eax, [ebx+dlgitemtemplate.type]
1306
        dec     eax
1389
        dec     eax
1307
        jz      .draw_text
1390
        jz      .draw_text
1308
        dec     eax
1391
        dec     eax
1309
        jz      .draw_button
1392
        jz      .draw_button
1310
        dec     eax
1393
        dec     eax
1311
        jnz     .draw_loop_continue
1394
        jnz     .draw_loop_continue
1312
        call    draw_editbox
1395
        call    draw_editbox
1313
        jmp     .draw_loop_continue
1396
        jmp     .draw_loop_continue
1314
.draw_button:
1397
.draw_button:
1315
        call    draw_button
1398
        call    draw_button
1316
        jmp     .draw_loop_continue
1399
        jmp     .draw_loop_continue
1317
.draw_text:
1400
.draw_text:
1318
        call    draw_static_text
1401
        call    draw_static_text
1319
.draw_loop_continue:
1402
.draw_loop_continue:
1320
        pop     ecx
1403
        pop     ecx
1321
        add     ebx, dlgitemtemplate.size
1404
        add     ebx, dlgitemtemplate.size
1322
        loop    .draw_loop
1405
        loop    .draw_loop
1323
.done_draw:
1406
.done_draw:
1324
        ret
1407
        ret
1325
 
1408
 
1326
draw_static_text:
1409
draw_static_text:
1327
; à¨á㥬 áâ â¨ç¥áª¨© ⥪áâ
1410
; à¨á㥬 áâ â¨ç¥áª¨© ⥪áâ
1328
        mov     ah, [dialog_main_color]
1411
        mov     ah, [dialog_main_color]
1329
        test    byte [ebp+dlgtemplate.flags], 2
1412
        test    byte [ebp+dlgtemplate.flags], 2
1330
        jz      draw_text
1413
        jz      draw_text
1331
        mov     ah, [warning_main_color]
1414
        mov     ah, [warning_main_color]
1332
draw_text:
1415
draw_text:
1333
; ®¯à¥¤¥«ï¥¬ ¤«¨­ã áâப¨
1416
; ®¯à¥¤¥«ï¥¬ ¤«¨­ã áâப¨
1334
        mov     esi, [ebx+dlgitemtemplate.data]
1417
        mov     esi, [ebx+dlgitemtemplate.data]
1335
draw_text_esi:
1418
draw_text_esi:
1336
        test    esi, esi
1419
        test    esi, esi
1337
        jz      .ret
1420
        jz      .ret
1338
        push    -1
1421
        push    -1
1339
        pop     ecx
1422
        pop     ecx
1340
@@:
1423
@@:
1341
        inc     ecx
1424
        inc     ecx
1342
        cmp     byte [ecx+esi], 0
1425
        cmp     byte [ecx+esi], 0
1343
        jnz     @b
1426
        jnz     @b
1344
; ¢ ecx ¤«¨­  áâப¨
1427
; ¢ ecx ¤«¨­  áâப¨
1345
        push    eax
1428
        push    eax
1346
        xor     eax, eax
1429
        xor     eax, eax
1347
        mov     edx, [ebx+dlgitemtemplate.x2]
1430
        mov     edx, [ebx+dlgitemtemplate.x2]
1348
        sub     edx, [ebx+dlgitemtemplate.x1]
1431
        sub     edx, [ebx+dlgitemtemplate.x1]
1349
        inc     edx
1432
        inc     edx
1350
        cmp     ecx, edx
1433
        cmp     ecx, edx
1351
        jae     .text_draw
1434
        jae     .text_draw
1352
        mov     al, byte [ebx+dlgitemtemplate.flags]
1435
        mov     al, byte [ebx+dlgitemtemplate.flags]
1353
        and     al, 3
1436
        and     al, 3
1354
        jz      .text_align_left
1437
        jz      .text_align_left
1355
        cmp     al, 1
1438
        cmp     al, 1
1356
        jz      .text_align_center
1439
        jz      .text_align_center
1357
; ⥪áâ ¢ë஢­¥­ ¢¯à ¢®
1440
; ⥪áâ ¢ë஢­¥­ ¢¯à ¢®
1358
        mov     eax, edx
1441
        mov     eax, edx
1359
        sub     eax, ecx
1442
        sub     eax, ecx
1360
        jmp     .text_draw
1443
        jmp     .text_draw
1361
.text_align_center:
1444
.text_align_center:
1362
        mov     eax, edx
1445
        mov     eax, edx
1363
        sub     eax, ecx
1446
        sub     eax, ecx
1364
        shr     eax, 1
1447
        shr     eax, 1
1365
        jmp     .text_draw
1448
        jmp     .text_draw
1366
.text_align_left:
1449
.text_align_left:
1367
        xor     eax, eax
1450
        xor     eax, eax
1368
.text_draw:
1451
.text_draw:
1369
        push    ecx
1452
        push    ecx
1370
        push    eax
1453
        push    eax
1371
        mov     eax, [ebx+dlgitemtemplate.x1]
1454
        mov     eax, [ebx+dlgitemtemplate.x1]
1372
        add     eax, [ebp+dlgtemplate.x]
1455
        add     eax, [ebp+dlgtemplate.x]
1373
        push    edx
1456
        push    edx
1374
        mov     edx, [ebx+dlgitemtemplate.y1]
1457
        mov     edx, [ebx+dlgitemtemplate.y1]
1375
        add     edx, [ebp+dlgtemplate.y]
1458
        add     edx, [ebp+dlgtemplate.y]
1376
        call    get_console_ptr
1459
        call    get_console_ptr
1377
        pop     edx
1460
        pop     edx
1378
        pop     ecx
1461
        pop     ecx
1379
        mov     ah, [esp+5]
1462
        mov     ah, [esp+5]
1380
        mov     al, ' '
1463
        mov     al, ' '
1381
        rep     stosw
1464
        rep     stosw
1382
        pop     ecx
1465
        pop     ecx
1383
        cmp     ecx, edx
1466
        cmp     ecx, edx
1384
        jbe     .text_copy
1467
        jbe     .text_copy
1385
        cmp     [ebx+dlgitemtemplate.type], 3
1468
        cmp     [ebx+dlgitemtemplate.type], 3
1386
        jnz     @f
1469
        jnz     @f
1387
        mov     ecx, edx
1470
        mov     ecx, edx
1388
        jmp     .text_copy
1471
        jmp     .text_copy
1389
@@:
1472
@@:
1390
        cmp     edx, 3
1473
        cmp     edx, 3
1391
        jb      .ret
1474
        jb      .ret
1392
        mov     al, '.'
1475
        mov     al, '.'
1393
        stosw
1476
        stosw
1394
        stosw
1477
        stosw
1395
        stosw
1478
        stosw
1396
        add     esi, ecx
1479
        add     esi, ecx
1397
        mov     ecx, edx
1480
        mov     ecx, edx
1398
        sub     ecx, 3
1481
        sub     ecx, 3
1399
        sub     esi, ecx
1482
        sub     esi, ecx
1400
.text_copy:
1483
.text_copy:
1401
        jecxz   .ret
1484
        jecxz   .ret
1402
; check for password editboxes
1485
; check for password editboxes
1403
        cmp     [ebx+dlgitemtemplate.type], 3
1486
        cmp     [ebx+dlgitemtemplate.type], 3
1404
        jnz     @f
1487
        jnz     @f
1405
        test    [ebx+dlgitemtemplate.flags], 20h
1488
        test    [ebx+dlgitemtemplate.flags], 20h
1406
        jz      @f
1489
        jz      @f
1407
        mov     al, '*'
1490
        mov     al, '*'
1408
        rep     stosw
1491
        rep     stosw
1409
        jmp     .ret
1492
        jmp     .ret
1410
@@:
1493
@@:
1411
        lodsb
1494
        lodsb
1412
        stosw
1495
        stosw
1413
        loop    @b
1496
        loop    @b
1414
.ret:
1497
.ret:
1415
        mov     eax, [ebp+dlgtemplate.x]
1498
        mov     eax, [ebp+dlgtemplate.x]
1416
        mov     edx, [ebp+dlgtemplate.y]
1499
        mov     edx, [ebp+dlgtemplate.y]
1417
        add     eax, [ebx+dlgitemtemplate.x2]
1500
        add     eax, [ebx+dlgitemtemplate.x2]
1418
        inc     eax
1501
        inc     eax
1419
        add     edx, [ebx+dlgitemtemplate.y1]
1502
        add     edx, [ebx+dlgitemtemplate.y1]
1420
        mov     ecx, edi
1503
        mov     ecx, edi
1421
        call    get_console_ptr
1504
        call    get_console_ptr
1422
        xchg    ecx, edi
1505
        xchg    ecx, edi
1423
        sub     ecx, edi
1506
        sub     ecx, edi
1424
        shr     ecx, 1
1507
        shr     ecx, 1
1425
        pop     eax
1508
        pop     eax
1426
        mov     al, ' '
1509
        mov     al, ' '
1427
        rep     stosw
1510
        rep     stosw
1428
        ret
1511
        ret
1429
 
1512
 
1430
draw_button:
1513
draw_button:
1431
        mov     ecx, dialog_colors
1514
        mov     ecx, dialog_colors
1432
        test    byte [ebp+dlgtemplate.flags], 2
1515
        test    byte [ebp+dlgtemplate.flags], 2
1433
        jz      @f
1516
        jz      @f
1434
        mov     ecx, warning_colors
1517
        mov     ecx, warning_colors
1435
@@:
1518
@@:
1436
        mov     ah, [dialog_normal_btn_color-dialog_colors+ecx]
1519
        mov     ah, [dialog_normal_btn_color-dialog_colors+ecx]
1437
        test    [ebx+dlgitemtemplate.flags], 4
1520
        test    [ebx+dlgitemtemplate.flags], 4
1438
        jz      @f
1521
        jz      @f
1439
        mov     ah, [dialog_selected_btn_color-dialog_colors+ecx]
1522
        mov     ah, [dialog_selected_btn_color-dialog_colors+ecx]
1440
@@:
1523
@@:
1441
        jmp     draw_text
1524
        jmp     draw_text
1442
 
1525
 
1443
draw_editbox:
1526
draw_editbox:
1444
        mov     edx, [ebx+dlgitemtemplate.data]
1527
        mov     edx, [ebx+dlgitemtemplate.data]
1445
        test    [ebx+dlgitemtemplate.flags], 4
1528
        test    [ebx+dlgitemtemplate.flags], 4
1446
        jz      @f
1529
        jz      @f
1447
        mov     eax, [ebx+dlgitemtemplate.x1]
1530
        mov     eax, [ebx+dlgitemtemplate.x1]
1448
        add     eax, [edx+4]
1531
        add     eax, [edx+4]
1449
        sub     eax, [edx+8]
1532
        sub     eax, [edx+8]
1450
        add     eax, [ebp+dlgtemplate.x]
1533
        add     eax, [ebp+dlgtemplate.x]
1451
        mov     [cursor_x], eax
1534
        mov     [cursor_x], eax
1452
        mov     eax, [ebx+dlgitemtemplate.y1]
1535
        mov     eax, [ebx+dlgitemtemplate.y1]
1453
        add     eax, [ebp+dlgtemplate.y]
1536
        add     eax, [ebp+dlgtemplate.y]
1454
        mov     [cursor_y], eax
1537
        mov     [cursor_y], eax
1455
@@:
1538
@@:
1456
        mov     ecx, dialog_colors
1539
        mov     ecx, dialog_colors
1457
        test    byte [ebp+dlgtemplate.flags], 2
1540
        test    byte [ebp+dlgtemplate.flags], 2
1458
        jz      @f
1541
        jz      @f
1459
        mov     ecx, warning_colors
1542
        mov     ecx, warning_colors
1460
@@:
1543
@@:
1461
        mov     ah, [dialog_edit_color-dialog_colors+ecx]
1544
        mov     ah, [dialog_edit_color-dialog_colors+ecx]
1462
        test    [ebx+dlgitemtemplate.flags], 10h
1545
        test    [ebx+dlgitemtemplate.flags], 10h
1463
        jnz     @f
1546
        jnz     @f
1464
        mov     ah, [dialog_unmodified_edit_color-dialog_colors+ecx]
1547
        mov     ah, [dialog_unmodified_edit_color-dialog_colors+ecx]
1465
@@:
1548
@@:
1466
        mov     esi, [ebx+dlgitemtemplate.data]
1549
        mov     esi, [ebx+dlgitemtemplate.data]
1467
        add     esi, [edx+8]
1550
        add     esi, [edx+8]
1468
        add     esi, 12
1551
        add     esi, 12
1469
        jmp     draw_text_esi
1552
        jmp     draw_text_esi
1470
 
1553
 
1471
; void __stdcall SayNoMem(void);
1554
; void __stdcall SayNoMem(void);
1472
SayNoMem:
1555
SayNoMem:
1473
        or      dword [nomem_dlgdata+4], -1
1556
        or      dword [nomem_dlgdata+4], -1
1474
        or      dword [nomem_dlgdata+8], -1
1557
        or      dword [nomem_dlgdata+8], -1
1475
        push    nomem_dlgdata
1558
        push    nomem_dlgdata
1476
        call    DialogBox
1559
        call    DialogBox
1477
        ret
1560
        ret
1478
 
1561
 
1479
; int __stdcall SayErr(int num_strings, const char* strings[],
1562
; int __stdcall SayErr(int num_strings, const char* strings[],
1480
;                      int num_buttons, const char* buttons[]);
1563
;                      int num_buttons, const char* buttons[]);
1481
SayErr:
1564
SayErr:
1482
        pop     eax
1565
        pop     eax
1483
        push    aError
1566
        push    aError
1484
        push    eax
1567
        push    eax
-
 
1568
; int __stdcall SayErrTitle(const char* title,
-
 
1569
;                       int num_strings, const char* strings[],
-
 
1570
;                       int num_buttons, const char* buttons[]);
-
 
1571
SayErrTitle:
1485
        push    2
1572
        push    2
1486
        jmp     @f
1573
        jmp     @f
1487
 
1574
 
1488
; int __stdcall Message(const char* title,
1575
; int __stdcall Message(const char* title,
1489
;                       int num_strings, const char* strings[],
1576
;                       int num_strings, const char* strings[],
1490
;                       int num_buttons, const char* buttons[]);
1577
;                       int num_buttons, const char* buttons[]);
1491
Message:
1578
Message:
1492
        push    1
1579
        push    1
1493
@@:
1580
@@:
1494
        pop     eax
1581
        pop     eax
1495
; [esp+4] = title
1582
; [esp+4] = title
1496
; [esp+8] = num_strings
1583
; [esp+8] = num_strings
1497
; [esp+12] = strings
1584
; [esp+12] = strings
1498
; [esp+16] = num_buttons
1585
; [esp+16] = num_buttons
1499
; [esp+20] = buttons
1586
; [esp+20] = buttons
1500
        pushad
1587
        pushad
1501
        mov     ecx, [esp+32+8]
1588
        mov     ecx, [esp+32+8]
1502
        add     ecx, [esp+32+16]
1589
        add     ecx, [esp+32+16]
1503
        imul    ecx, dlgitemtemplate.size
1590
        imul    ecx, dlgitemtemplate.size
1504
        add     ecx, dlgtemplate.size+12
1591
        add     ecx, dlgtemplate.size+12
1505
        call    xpgalloc
1592
        call    xpgalloc
1506
        test    eax, eax
1593
        test    eax, eax
1507
        jnz     @f
1594
        jnz     @f
1508
        popad
1595
        popad
1509
        or      eax, -1
1596
        or      eax, -1
1510
        ret     28
1597
        ret     28
1511
@@:
1598
@@:
1512
        mov     ebx, eax
1599
        mov     ebx, eax
1513
        mov     edi, eax
1600
        mov     edi, eax
1514
        mov     eax, [esp+28]
1601
        mov     eax, [esp+28]
1515
        stosd                           ; dlgtemplate.flags
1602
        stosd                           ; dlgtemplate.flags
1516
        or      eax, -1
1603
        or      eax, -1
1517
        stosd                           ; dlgtemplate.x
1604
        stosd                           ; dlgtemplate.x
1518
        stosd                           ; dlgtemplate.y
1605
        stosd                           ; dlgtemplate.y
1519
; calculate width
1606
; calculate width
1520
        mov     ecx, [esp+32+8]
1607
        mov     ecx, [esp+32+8]
1521
        mov     esi, [esp+32+12]
1608
        mov     esi, [esp+32+12]
1522
        xor     edx, edx
1609
        xor     edx, edx
1523
.calcwidth:
1610
.calcwidth:
1524
        lodsd
1611
        lodsd
1525
@@:
1612
@@:
1526
        inc     eax
1613
        inc     eax
1527
        cmp     byte [eax-1], 0
1614
        cmp     byte [eax-1], 0
1528
        jnz     @b
1615
        jnz     @b
1529
        sub     eax, [esi-4]
1616
        sub     eax, [esi-4]
1530
        inc     eax
1617
        inc     eax
1531
        cmp     edx, eax
1618
        cmp     edx, eax
1532
        ja      @f
1619
        ja      @f
1533
        mov     edx, eax
1620
        mov     edx, eax
1534
@@:
1621
@@:
1535
        loop    .calcwidth
1622
        loop    .calcwidth
1536
        mov     ecx, [esp+32+16]
1623
        mov     ecx, [esp+32+16]
1537
        mov     esi, [esp+32+20]
1624
        mov     esi, [esp+32+20]
1538
        xor     ebp, ebp
1625
        xor     ebp, ebp
1539
.calcwidth2:
1626
.calcwidth2:
1540
        lodsd
1627
        lodsd
1541
@@:
1628
@@:
1542
        inc     eax
1629
        inc     eax
1543
        cmp     byte [eax-1], 0
1630
        cmp     byte [eax-1], 0
1544
        jnz     @b
1631
        jnz     @b
1545
        sub     eax, [esi-4]
1632
        sub     eax, [esi-4]
1546
        inc     eax
1633
        inc     eax
1547
        add     ebp, eax
1634
        add     ebp, eax
1548
        loop    .calcwidth2
1635
        loop    .calcwidth2
1549
        inc     ebp
1636
        inc     ebp
1550
        inc     ebp
1637
        inc     ebp
1551
        cmp     edx, ebp
1638
        cmp     edx, ebp
1552
        ja      @f
1639
        ja      @f
1553
        mov     edx, ebp
1640
        mov     edx, ebp
1554
@@:
1641
@@:
1555
        mov     eax, [cur_width]
1642
        mov     eax, [cur_width]
1556
        sub     eax, 8
1643
        sub     eax, 8
1557
        cmp     edx, eax
1644
        cmp     edx, eax
1558
        jb      @f
1645
        jb      @f
1559
        mov     edx, eax
1646
        mov     edx, eax
1560
@@:
1647
@@:
1561
        mov     eax, edx
1648
        mov     eax, edx
1562
        stosd                           ; dlgtemplate.width
1649
        stosd                           ; dlgtemplate.width
1563
        mov     eax, [esp+32+8]
1650
        mov     eax, [esp+32+8]
1564
        inc     eax
1651
        inc     eax
1565
        stosd                           ; dlgtemplate.height
1652
        stosd                           ; dlgtemplate.height
1566
        mov     eax, 3
1653
        mov     eax, 3
1567
        stosd                           ; dlgtemplate.border_size_x
1654
        stosd                           ; dlgtemplate.border_size_x
1568
        mov     al, 2
1655
        mov     al, 2
1569
        stosd                           ; dlgtemplate.border_size_y
1656
        stosd                           ; dlgtemplate.border_size_y
1570
        mov     eax, [esp+32+4]
1657
        mov     eax, [esp+32+4]
1571
        stosd                           ; dlgtemplate.title
1658
        stosd                           ; dlgtemplate.title
1572
        xor     eax, eax
1659
        xor     eax, eax
1573
        stosd                           ; (ignored)
1660
        stosd                           ; (ignored)
-
 
1661
        stosd                           ; (ignored)
1574
        stosd                           ; DlgProc
1662
        stosd                           ; DlgProc
1575
        stosd                           ; userdata
1663
        stosd                           ; userdata
1576
        mov     eax, [esp+32+8]
1664
        mov     eax, [esp+32+8]
1577
        add     eax, [esp+32+16]
1665
        add     eax, [esp+32+16]
1578
        stosd                           ; num_items
1666
        stosd                           ; num_items
1579
; fill strings
1667
; fill strings
1580
        xor     ecx, ecx
1668
        xor     ecx, ecx
1581
        mov     esi, [esp+32+12]
1669
        mov     esi, [esp+32+12]
1582
@@:
1670
@@:
1583
        mov     eax, 1
1671
        mov     eax, 1
1584
        stosd                           ; dlgitemtemplate.type
1672
        stosd                           ; dlgitemtemplate.type
1585
        dec     eax
1673
        dec     eax
1586
        stosd                           ; dlgitemtemplate.x1
1674
        stosd                           ; dlgitemtemplate.x1
1587
        mov     eax, ecx
1675
        mov     eax, ecx
1588
        stosd                           ; dlgitemtemplate.y1
1676
        stosd                           ; dlgitemtemplate.y1
1589
        lea     eax, [edx-1]
1677
        lea     eax, [edx-1]
1590
        stosd                           ; dlgitemtemplate.x2
1678
        stosd                           ; dlgitemtemplate.x2
1591
        mov     eax, ecx
1679
        mov     eax, ecx
1592
        stosd                           ; dlgitemtemplate.y2
1680
        stosd                           ; dlgitemtemplate.y2
1593
        movsd                           ; dlgitemtemplate.data
1681
        movsd                           ; dlgitemtemplate.data
1594
        mov     eax, 1
1682
        mov     eax, 1
1595
        stosd                           ; dlgitemtemplate.flags
1683
        stosd                           ; dlgitemtemplate.flags
1596
        inc     ecx
1684
        inc     ecx
1597
        cmp     ecx, [esp+32+8]
1685
        cmp     ecx, [esp+32+8]
1598
        jb      @b
1686
        jb      @b
1599
; fill buttons
1687
; fill buttons
1600
        mov     ecx, [esp+32+16]
1688
        mov     ecx, [esp+32+16]
1601
        mov     esi, [esp+32+20]
1689
        mov     esi, [esp+32+20]
1602
        sub     edx, ebp
1690
        sub     edx, ebp
1603
        jc      .big
1691
        jc      .big
1604
        shr     edx, 1
1692
        shr     edx, 1
1605
        inc     edx
1693
        inc     edx
1606
        jmp     .fillbtns
1694
        jmp     .fillbtns
1607
.big:
1695
.big:
1608
        xor     edx, edx
1696
        xor     edx, edx
1609
.fillbtns:
1697
.fillbtns:
1610
        mov     eax, 2
1698
        mov     eax, 2
1611
        stosd                           ; dlgitemtemplate.type
1699
        stosd                           ; dlgitemtemplate.type
1612
        mov     eax, edx
1700
        mov     eax, edx
1613
        stosd                           ; dlgitemtemplate.x1
1701
        stosd                           ; dlgitemtemplate.x1
1614
        mov     eax, [ebx+dlgtemplate.height]
1702
        mov     eax, [ebx+dlgtemplate.height]
1615
        dec     eax
1703
        dec     eax
1616
        stosd                           ; dlgitemtemplate.y1
1704
        stosd                           ; dlgitemtemplate.y1
1617
        push    eax
1705
        push    eax
1618
        lodsd
1706
        lodsd
1619
        sub     eax, edx
1707
        sub     eax, edx
1620
@@:
1708
@@:
1621
        inc     edx
1709
        inc     edx
1622
        cmp     byte [eax+edx-1], 0
1710
        cmp     byte [eax+edx-1], 0
1623
        jnz     @b
1711
        jnz     @b
1624
        mov     eax, edx
1712
        mov     eax, edx
1625
        inc     edx
1713
        inc     edx
1626
        stosd                           ; dlgitemtemplate.x2
1714
        stosd                           ; dlgitemtemplate.x2
1627
        pop     eax
1715
        pop     eax
1628
        stosd                           ; dlgitemtemplate.y2
1716
        stosd                           ; dlgitemtemplate.y2
1629
        mov     eax, [esi-4]
1717
        mov     eax, [esi-4]
1630
        stosd                           ; dlgitemtemplate.data
1718
        stosd                           ; dlgitemtemplate.data
1631
        mov     eax, 9
1719
        mov     eax, 9
1632
        cmp     ecx, [esp+32+16]
1720
        cmp     ecx, [esp+32+16]
1633
        jnz     @f
1721
        jnz     @f
1634
        or      al, 4
1722
        or      al, 4
1635
@@:
1723
@@:
1636
        stosd                           ; dlgitemtemplate.flags
1724
        stosd                           ; dlgitemtemplate.flags
1637
        loop    .fillbtns
1725
        loop    .fillbtns
1638
        push    ebx
1726
        push    ebx
1639
        call    DialogBox
1727
        call    DialogBox
1640
        cmp     eax, -1
1728
        cmp     eax, -1
1641
        jz      @f
1729
        jz      @f
1642
        sub     eax, ebx
1730
        sub     eax, ebx
1643
        sub     eax, dlgtemplate.size+12
1731
        sub     eax, dlgtemplate.size+12
1644
        xor     edx, edx
1732
        xor     edx, edx
1645
        mov     ecx, dlgitemtemplate.size
1733
        mov     ecx, dlgitemtemplate.size
1646
        div     ecx
1734
        div     ecx
1647
        sub     eax, [esp+32+8]
1735
        sub     eax, [esp+32+8]
1648
@@:
1736
@@:
1649
        mov     [esp+28], eax
1737
        mov     [esp+28], eax
1650
        mov     ecx, ebx
1738
        mov     ecx, ebx
1651
        call    pgfree
1739
        call    pgfree
1652
        popad
1740
        popad
1653
        ret     20
1741
        ret     20