Subversion Repositories Kolibri OS

Rev

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

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