Subversion Repositories Kolibri OS

Rev

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

Rev 8484 Rev 8489
1
;******************************************************************************
1
;******************************************************************************
2
;   MAIN MENU
2
;   MAIN MENU
3
;******************************************************************************
3
;******************************************************************************
4
; last update:  17/04/2012
4
; last update:  17/04/2012
5
; changed by:   Marat Zakiyanov aka Mario79, aka Mario
5
; changed by:   Marat Zakiyanov aka Mario79, aka Mario
6
; changes:      Support for boot parameters.
6
; changes:      Support for boot parameters.
7
;------------------------------------------------------------------------------
7
;------------------------------------------------------------------------------
8
; last update:  22/03/2012
8
; last update:  22/03/2012
9
; changed by:   Marat Zakiyanov aka Mario79, aka Mario
9
; changed by:   Marat Zakiyanov aka Mario79, aka Mario
10
; changes:      Global optimization! The program uses
10
; changes:      Global optimization! The program uses
11
;               only 32 KB of memory instead of 128 kb is now.
11
;               only 32 KB of memory instead of 128 kb is now.
12
;------------------------------------------------------------------------------
12
;------------------------------------------------------------------------------
13
; last update:  19/09/2011
13
; last update:  19/09/2011
14
; changed by:   Marat Zakiyanov aka Mario79, aka Mario
14
; changed by:   Marat Zakiyanov aka Mario79, aka Mario
15
; changes:      Checking for program exist to memory
15
; changes:      Checking for program exist to memory
16
;               Added processing of keys: left and right arrow
16
;               Added processing of keys: left and right arrow
17
;------------------------------------------------------------------------------
17
;------------------------------------------------------------------------------
18
;   MAIN MENU by lisovin@26.ru
18
;   MAIN MENU by lisovin@26.ru
19
;   Some parts of code rewritten by Ivan Poddubny 
19
;   Some parts of code rewritten by Ivan Poddubny 
20
;
20
;
21
;   Compile with FASM for Menuet
21
;   Compile with FASM for Kolibri
22
;******************************************************************************
22
;******************************************************************************
23
  BTN_HEIGHT         = 22  ;26
23
  BTN_HEIGHT         = 26
24
  BTN_WIDTH          = 140 ;178
24
  BTN_WIDTH          = 178
25
  TXT_Y              = (BTN_HEIGHT)/2-4
25
  TXT_Y              = (BTN_HEIGHT)/2-6
26
  FONT_TYPE          = 0x80000000 ;0x90000000
26
  FONT_TYPE          = 0x90000000
27
 
27
 
28
  PANEL_HEIGHT       = 20
28
  PANEL_HEIGHT       = 20
29
  MENU_BOTTON_X_POS  = 10
29
  MENU_BOTTON_X_POS  = 10
30
  MENU_BOTTON_X_SIZE = 50
30
  MENU_BOTTON_X_SIZE = 50
31
;------------------------------------------------------------------------------
31
;------------------------------------------------------------------------------
32
	use32
32
	use32
33
	org 0x0
33
	org 0x0
34
 
34
 
35
	db 'MENUET01'  ; 8 byte id
35
	db 'MENUET01'  ; 8 byte id
36
	dd 0x01        ; header version
36
	dd 0x01        ; header version
37
	dd START       ; start of code
37
	dd START       ; start of code
38
	dd IM_END      ; size of image
38
	dd IM_END      ; size of image
39
	dd mem_end     ; memory for app
39
	dd mem_end     ; memory for app
40
	dd stack_area  ; esp
40
	dd stack_area  ; esp
41
	dd bootparam   ; boot parameters
41
	dd bootparam   ; boot parameters
42
	dd 0x0         ; path
42
	dd 0x0         ; path
43
;------------------------------------------------------------------------------
43
;------------------------------------------------------------------------------
44
include "..\..\..\macros.inc"
44
include "..\..\..\macros.inc"
45
include "..\..\..\gui_patterns.inc"
45
include "..\..\..\gui_patterns.inc"
46
;include "../../../debug.inc"             ; debug macros
46
;include "../../../debug.inc"             ; debug macros
47
;------------------------------------------------------------------------------
47
;------------------------------------------------------------------------------
48
align 4
48
align 4
49
conversion_ASCII_to_HEX:
49
conversion_ASCII_to_HEX:
50
	xor	ebx,ebx
50
	xor	ebx,ebx
51
	cld
51
	cld
52
	lodsd
52
	lodsd
53
	mov	ecx,4
53
	mov	ecx,4
54
;--------------------------------------
54
;--------------------------------------
55
align 4
55
align 4
56
.loop:
56
.loop:
57
	cmp	al,0x60	; check for ABCDEF
57
	cmp	al,0x60	; check for ABCDEF
58
	ja	@f
58
	ja	@f
59
	sub	al,0x30 ; 0-9
59
	sub	al,0x30 ; 0-9
60
	jmp	.store
60
	jmp	.store
61
;--------------------------------------
61
;--------------------------------------
62
align 4
62
align 4
63
@@:
63
@@:
64
	sub	al,0x57 ; A-F
64
	sub	al,0x57 ; A-F
65
;--------------------------------------
65
;--------------------------------------
66
align 4
66
align 4
67
.store:
67
.store:
68
	and	al,0xf
68
	and	al,0xf
69
	rol	ebx,4
69
	rol	ebx,4
70
	add	bl,al
70
	add	bl,al
71
	ror	eax,8
71
	ror	eax,8
72
	dec	ecx
72
	dec	ecx
73
	jnz	.loop
73
	jnz	.loop
74
 
74
 
75
	ret
75
	ret
76
;------------------------------------------------------------------------------
76
;------------------------------------------------------------------------------
77
align 4
77
align 4
78
START:		       ; start of execution
78
START:		       ; start of execution
79
	mcall	68,11
79
	mcall	68,11
80
	
80
	
81
	mcall 30, 1, default_dir
81
	mcall 30, 1, default_dir
82
 
82
 
83
	mov	esi,bootparam	
83
	mov	esi,bootparam	
84
	cmp	[esi],byte 0
84
	cmp	[esi],byte 0
85
	je	.no_boot_parameters
85
	je	.no_boot_parameters
86
; boot params - hex
86
; boot params - hex
87
; db '9999'	; +0	Menu button X
87
; db '9999'	; +0	Menu button X
88
; db '9999'	; +4	Menu button X size
88
; db '9999'	; +4	Menu button X size
89
; db '9999'	; +8	Menu button Y
89
; db '9999'	; +8	Menu button Y
90
; db '9999'	; +12	Menu button Y size
90
; db '9999'	; +12	Menu button Y size
91
; db '9999'	; +16	Panel height
91
; db '9999'	; +16	Panel height
92
; db '1000'	; +20	Panel attachment
92
; db '1000'	; +20	Panel attachment
93
 
93
 
94
;	mov	edx,bootparam
94
;	mov	edx,bootparam
95
;	call	debug_outstr
95
;	call	debug_outstr
96
;	newline
96
;	newline
97
 
97
 
98
	call	conversion_ASCII_to_HEX
98
	call	conversion_ASCII_to_HEX
99
	mov	[menu_button_x.start],ebx
99
	mov	[menu_button_x.start],ebx
100
	
100
	
101
;	dps	"menu_button_x.start: "
101
;	dps	"menu_button_x.start: "
102
;	dpd	ebx
102
;	dpd	ebx
103
;	newline
103
;	newline
104
 
104
 
105
	call	conversion_ASCII_to_HEX
105
	call	conversion_ASCII_to_HEX
106
	mov	[menu_button_x.size],ebx
106
	mov	[menu_button_x.size],ebx
107
 
107
 
108
;	dps	"menu_button_x.size: "
108
;	dps	"menu_button_x.size: "
109
;	dpd	ebx
109
;	dpd	ebx
110
;	newline
110
;	newline
111
 
111
 
112
	call	conversion_ASCII_to_HEX
112
	call	conversion_ASCII_to_HEX
113
	mov	[menu_button_y.start],ebx
113
	mov	[menu_button_y.start],ebx
114
 
114
 
115
;	dps	"menu_button_y.start: "
115
;	dps	"menu_button_y.start: "
116
;	dpd	ebx
116
;	dpd	ebx
117
;	newline
117
;	newline
118
	
118
	
119
	call	conversion_ASCII_to_HEX
119
	call	conversion_ASCII_to_HEX
120
	mov	[menu_button_y.size],ebx
120
	mov	[menu_button_y.size],ebx
121
	
121
	
122
;	dps	"menu_button_y.size: "
122
;	dps	"menu_button_y.size: "
123
;	dpd	ebx
123
;	dpd	ebx
124
;	newline
124
;	newline
125
	
125
	
126
	call	conversion_ASCII_to_HEX
126
	call	conversion_ASCII_to_HEX
127
	mov	[panel_height],ebx
127
	mov	[panel_height],ebx
128
 
128
 
129
;	dps	"panel_height: "
129
;	dps	"panel_height: "
130
;	dpd	ebx
130
;	dpd	ebx
131
;	newline
131
;	newline
132
	
132
	
133
	call	conversion_ASCII_to_HEX
133
	call	conversion_ASCII_to_HEX
134
	mov	[panel_attachment],ebx
134
	mov	[panel_attachment],ebx
135
	
135
	
136
;	dps	"panel_attachment: "
136
;	dps	"panel_attachment: "
137
;	dpd	ebx
137
;	dpd	ebx
138
;	newline
138
;	newline
139
;--------------------------------------
139
;--------------------------------------
140
align 4	
140
align 4	
141
.no_boot_parameters:
141
.no_boot_parameters:
142
	call	program_exist
142
	call	program_exist
143
	mcall	14
143
	mcall	14
144
	mov	[screen_size],eax
144
	mov	[screen_size],eax
145
	
145
	
146
	mcall	48,3,sc,sizeof.system_colors	; load system colors
146
	mcall	48,3,sc,sizeof.system_colors	; load system colors
147
	
147
	
148
; get size of file MENU.DAT
148
; get size of file MENU.DAT
149
	mcall	70,fileinfo
149
	mcall	70,fileinfo
150
	test	eax,eax
150
	test	eax,eax
151
	jnz	close
151
	jnz	close
152
; get memory for MENU.DAT
152
; get memory for MENU.DAT
153
	mov	ecx,[procinfo+32]
153
	mov	ecx,[procinfo+32]
154
	mov	[fileinfo.size],ecx
154
	mov	[fileinfo.size],ecx
155
	mcall	68,12
155
	mcall	68,12
156
	mov	[fileinfo.return],eax
156
	mov	[fileinfo.return],eax
157
	mcall	68
157
	mcall	68
158
	mov	[menu_data],eax
158
	mov	[menu_data],eax
159
; load MENU.DAT
159
; load MENU.DAT
160
	mov	[fileinfo],dword 0
160
	mov	[fileinfo],dword 0
161
	mcall	70,fileinfo
161
	mcall	70,fileinfo
162
	test	eax,eax
162
	test	eax,eax
163
	jnz	close
163
	jnz	close
164
 
164
 
165
	test	ebx,ebx	   ; length = 0 ?
165
	test	ebx,ebx	   ; length = 0 ?
166
	jz	close
166
	jz	close
167
	mov	ecx,ebx
167
	mov	ecx,ebx
168
	mov	edi,[fileinfo.return]	;mem_end
168
	mov	edi,[fileinfo.return]	;mem_end
169
;--------------------------------------
169
;--------------------------------------
170
align 4
170
align 4
171
newsearch:
171
newsearch:
172
	mov	al,'#'
172
	mov	al,'#'
173
	cld
173
	cld
174
	repne	scasb
174
	repne	scasb
175
	test	ecx,ecx	   ; if not found
175
	test	ecx,ecx	   ; if not found
176
	jz	close
176
	jz	close
177
	call	get_number
177
	call	get_number
178
	test	ebx,ebx
178
	test	ebx,ebx
179
	jnz	.number
179
	jnz	.number
180
	cmp	al,'#'
180
	cmp	al,'#'
181
	je	search_end
181
	je	search_end
182
;--------------------------------------
182
;--------------------------------------
183
align 4
183
align 4
184
.number:
184
.number:
185
	shl	ebx,4
185
	shl	ebx,4
186
	add	ebx,[menu_data]     ; pointer to process table
186
	add	ebx,[menu_data]     ; pointer to process table
187
	mov	[ebx],edi
187
	mov	[ebx],edi
188
	inc	[processes]
188
	inc	[processes]
189
	jmp	newsearch
189
	jmp	newsearch
190
;--------------------------------------
190
;--------------------------------------
191
align 4
191
align 4
192
search_end:
192
search_end:
193
	mov	[end_pointer],edi
193
	mov	[end_pointer],edi
194
	mov	ebx,[processes]
194
	mov	ebx,[processes]
195
	dec	ebx
195
	dec	ebx
196
	shl	ebx,4
196
	shl	ebx,4
197
	add	ebx,[menu_data]
197
	add	ebx,[menu_data]
198
;--------------------------------------
198
;--------------------------------------
199
align 4
199
align 4
200
newprocess:
200
newprocess:
201
	xor	edx,edx
201
	xor	edx,edx
202
	mov	ecx,edi
202
	mov	ecx,edi
203
	sub	ecx,[ebx]
203
	sub	ecx,[ebx]
204
	mov	al,10
204
	mov	al,10
205
;--------------------------------------
205
;--------------------------------------
206
align 4
206
align 4
207
newsearch1:
207
newsearch1:
208
	std
208
	std
209
	repne	scasb
209
	repne	scasb
210
	test	ecx,ecx
210
	test	ecx,ecx
211
	je	endprocess
211
	je	endprocess
212
	cmp	[edi],byte 13
212
	cmp	[edi],byte 13
213
	jne	newsearch1
213
	jne	newsearch1
214
	inc	edx
214
	inc	edx
215
	jmp	newsearch1
215
	jmp	newsearch1
216
;--------------------------------------
216
;--------------------------------------
217
align 4
217
align 4
218
endprocess:
218
endprocess:
219
	mov	esi,ebx
219
	mov	esi,ebx
220
	add	esi,4
220
	add	esi,4
221
	dec	edx
221
	dec	edx
222
	mov	[esi],dl
222
	mov	[esi],dl
223
	cmp	ebx,[menu_data]
223
	cmp	ebx,[menu_data]
224
	jbe	search_end1
224
	jbe	search_end1
225
	sub	ebx,16
225
	sub	ebx,16
226
	jmp	newprocess
226
	jmp	newprocess
227
;--------------------------------------
227
;--------------------------------------
228
align 4
228
align 4
229
search_end1:
229
search_end1:
230
	mcall	14
230
	mcall	14
231
	cmp	[panel_attachment],byte 1
231
	cmp	[panel_attachment],byte 1
232
	je	@f
232
	je	@f
233
	xor	ax,ax
233
	xor	ax,ax
234
	jmp	.store
234
	jmp	.store
235
;--------------------------------------
235
;--------------------------------------
236
align 4	
236
align 4	
237
@@:
237
@@:
238
	sub	ax,[panel_height]	;20
238
	sub	ax,[panel_height]	;20
239
.store:
239
.store:
240
	mov	ebx,[menu_data]
240
	mov	ebx,[menu_data]
241
	mov	[ebx + y_end],ax
241
	mov	[ebx + y_end],ax
242
	mov	[ebx + x_start],5
242
	mov	[ebx + x_start],5
243
	mov	al,[ebx + rows]
243
	mov	al,[ebx + rows]
244
	mov	[ebx + cur_sel],al	 ; clear selection
244
	mov	[ebx + cur_sel],al	 ; clear selection
245
	mov	[ebx + prev_sel],al
245
	mov	[ebx + prev_sel],al
246
	mov	[buffer],0
246
	mov	[buffer],0
247
;------------------------------------------------------------------------------
247
;------------------------------------------------------------------------------
248
align 4
248
align 4
249
thread:
249
thread:
250
	mov	ebp,esp
250
	mov	ebp,esp
251
	sub	ebp,0x1000
251
	sub	ebp,0x1000
252
	cmp	ebp,0x2000 ; if this is first started thread
252
	cmp	ebp,0x2000 ; if this is first started thread
253
	ja	@f
253
	ja	@f
254
	xor	ebp,ebp ; not free area
254
	xor	ebp,ebp ; not free area
255
;--------------------------------------
255
;--------------------------------------
256
align 4
256
align 4
257
@@:
257
@@:
258
	mov	eax,[buffer]      ; identifier
258
	mov	eax,[buffer]      ; identifier
259
	shl	eax,4
259
	shl	eax,4
260
	add	eax,[menu_data]
260
	add	eax,[menu_data]
261
	mov	edi,eax
261
	mov	edi,eax
262
	mcall	40,100111b	; mouse + button + key + redraw
262
	mcall	40,100111b	; mouse + button + key + redraw
263
;------------------------------------------------------------------------------
263
;------------------------------------------------------------------------------
264
align 4
264
align 4
265
red:	
265
red:	
266
	call	draw_window	; redraw
266
	call	draw_window	; redraw
267
;------------------------------------------------------------------------------
267
;------------------------------------------------------------------------------
268
align 4
268
align 4
269
still:
269
still:
270
	call	free_area_if_set_mutex
270
	call	free_area_if_set_mutex
271
 
271
 
272
	mcall	23,5	; wait here for event
272
	mcall	23,5	; wait here for event
273
	test	[close_now],1      ; is close flag set?
273
	test	[close_now],1      ; is close flag set?
274
	jnz	close
274
	jnz	close
275
	
275
	
276
	cmp	eax,1	; redraw request ?
276
	cmp	eax,1	; redraw request ?
277
	je	red
277
	je	red
278
	cmp	eax,2	; key pressed ?
278
	cmp	eax,2	; key pressed ?
279
	je	key
279
	je	key
280
	cmp	eax,3	; button in buffer ?
280
	cmp	eax,3	; button in buffer ?
281
	je	button
281
	je	button
282
	cmp	eax,6	; mouse event ?
282
	cmp	eax,6	; mouse event ?
283
	je	mouse
283
	je	mouse
284
	cmp	edi,[menu_data]
284
	cmp	edi,[menu_data]
285
	je	still	     ; if main process-ignored
285
	je	still	     ; if main process-ignored
286
	
286
	
287
	movzx	ebx,[edi + parent]	 ; parent id
287
	movzx	ebx,[edi + parent]	 ; parent id
288
	shl	ebx,4
288
	shl	ebx,4
289
	add	ebx,[menu_data]      ; ebx = base of parent info
289
	add	ebx,[menu_data]      ; ebx = base of parent info
290
	call	backconvert	     ; get my id in al
290
	call	backconvert	     ; get my id in al
291
	cmp	al,[ebx + child]    ; if I'm not child of my parent, I shall die :)
291
	cmp	al,[ebx + child]    ; if I'm not child of my parent, I shall die :)
292
	jne	close
292
	jne	close
293
	
293
	
294
	jmp	still
294
	jmp	still
295
;------------------------------------------------------------------------------
295
;------------------------------------------------------------------------------
296
align 4
296
align 4
297
key:
297
key:
298
	mcall	2
298
	mcall	2
299
	mov	[last_key],ah
299
	mov	[last_key],ah
300
	mov	al,[edi + rows]     ; number of buttons
300
	mov	al,[edi + rows]     ; number of buttons
301
	cmp	ah,178	  ; KEY_UP
301
	cmp	ah,178	  ; KEY_UP
302
	jne	.noup
302
	jne	.noup
303
	
303
	
304
	mov	ah,[edi+cur_sel]
304
	mov	ah,[edi+cur_sel]
305
	mov	[edi+prev_sel],ah
305
	mov	[edi+prev_sel],ah
306
	dec	byte [edi+cur_sel]
306
	dec	byte [edi+cur_sel]
307
	jnz	redrawbut
307
	jnz	redrawbut
308
	mov	[edi+cur_sel],al
308
	mov	[edi+cur_sel],al
309
	jmp	redrawbut
309
	jmp	redrawbut
310
;--------------------------------------
310
;--------------------------------------
311
align 4
311
align 4
312
.noup:
312
.noup:
313
	cmp	ah,177	 ; KEY_DOWN
313
	cmp	ah,177	 ; KEY_DOWN
314
	jne	.nodn
314
	jne	.nodn
315
	
315
	
316
	mov	ah,[edi + cur_sel]
316
	mov	ah,[edi + cur_sel]
317
	mov	[edi + prev_sel],ah
317
	mov	[edi + prev_sel],ah
318
	inc	[edi + cur_sel]
318
	inc	[edi + cur_sel]
319
	cmp	[edi + cur_sel],al
319
	cmp	[edi + cur_sel],al
320
	jna	redrawbut
320
	jna	redrawbut
321
	mov	[edi + cur_sel],1
321
	mov	[edi + cur_sel],1
322
	jmp	redrawbut
322
	jmp	redrawbut
323
;--------------------------------------
323
;--------------------------------------
324
align 4
324
align 4
325
.nodn:
325
.nodn:
326
	cmp	ah,179 	 ; KEY_LEFT
326
	cmp	ah,179 	 ; KEY_LEFT
327
	je	@f
327
	je	@f
328
	cmp	ah,13 	 ; ENTER
328
	cmp	ah,13 	 ; ENTER
329
	jne	.noenter
329
	jne	.noenter
330
@@:
330
@@:
331
	mov	ah,[edi + cur_sel]
331
	mov	ah,[edi + cur_sel]
332
	jmp	button1
332
	jmp	button1
333
;--------------------------------------
333
;--------------------------------------
334
align 4
334
align 4
335
.noenter:
335
.noenter:
336
	cmp	ah,176 	 ; KEY_RIGHT
336
	cmp	ah,176 	 ; KEY_RIGHT
337
	je	@f
337
	je	@f
338
	cmp	ah,27 	 ; ESC
338
	cmp	ah,27 	 ; ESC
339
	jne	still
339
	jne	still
340
	jmp	close
340
	jmp	close
341
;--------------------------------------
341
;--------------------------------------
342
align 4
342
align 4
343
@@:
343
@@:
344
	call	get_process_ID
344
	call	get_process_ID
345
	cmp	[main_process_ID],ecx
345
	cmp	[main_process_ID],ecx
346
	jne	close
346
	jne	close
347
	jmp	still
347
	jmp	still
348
;------------------------------------------------------------------------------
348
;------------------------------------------------------------------------------
349
align 4
349
align 4
350
button:	; BUTTON HANDLER
350
button:	; BUTTON HANDLER
351
	mcall	17	; get id
351
	mcall	17	; get id
352
				; dunkaist[
352
				; dunkaist[
353
	test	eax,0xfffffe00	; is it system close button? (close signal from @taskbar)
353
	test	eax,0xfffffe00	; is it system close button? (close signal from @taskbar)
354
	setz	byte[close_now]	; set (or not set) close_recursive flag
354
	setz	byte[close_now]	; set (or not set) close_recursive flag
355
	jz	close		; if so,close all menus
355
	jz	close		; if so,close all menus
356
				; dunkaist]
356
				; dunkaist]
357
;--------------------------------------
357
;--------------------------------------
358
align 4
358
align 4
359
button1:
359
button1:
360
	mov	esi,edi
360
	mov	esi,edi
361
	push	edi
361
	push	edi
362
	mov	edi,[edi + pointer]
362
	mov	edi,[edi + pointer]
363
; print "hello"
363
; print "hello"
364
	mov	al,[esi + cur_sel]
364
	mov	al,[esi + cur_sel]
365
	mov	[esi + prev_sel],al
365
	mov	[esi + prev_sel],al
366
	mov	[esi + cur_sel],ah
366
	mov	[esi + cur_sel],ah
367
	
367
	
368
	pushad
368
	pushad
369
	mov	edi,esi
369
	mov	edi,esi
370
; dph eax
370
; dph eax
371
	call	draw_only_needed_buttons
371
	call	draw_only_needed_buttons
372
	popad
372
	popad
373
; look for the next line  times;  = button_id
373
; look for the next line  times;  = button_id
374
	push	eax
374
	push	eax
375
;--------------------------------------
375
;--------------------------------------
376
align 4
376
align 4
377
.next_string:
377
.next_string:
378
	call	searchstartstring
378
	call	searchstartstring
379
	dec	ah
379
	dec	ah
380
	jnz	.next_string
380
	jnz	.next_string
381
	pop	eax
381
	pop	eax
382
	
382
	
383
	mov	ecx,40
383
	mov	ecx,40
384
	mov	al,'|'
384
	mov	al,'|'
385
	cld
385
	cld
386
	repne	scasb
386
	repne	scasb
387
	test	ecx,ecx	  ; if '|' not found
387
	test	ecx,ecx	  ; if '|' not found
388
	je	searchexit
388
	je	searchexit
389
	
389
	
390
	cmp	[edi],byte '@'     ; check for submenu
390
	cmp	[edi],byte '@'     ; check for submenu
391
	je	runthread
391
	je	runthread
392
	
392
	
393
	cmp	[last_key],179
393
	cmp	[last_key],179
394
	je	searchexit
394
	je	searchexit
395
	
395
	
396
	;dec	edi
396
	;dec	edi
397
	push	edi			; pointer to start of filename
397
	push	edi			; pointer to start of filename
398
	call	searchstartstring	; search for next string
398
	call	searchstartstring	; search for next string
399
	sub	edi,2		; to last byte of string
399
	sub	edi,2		; to last byte of string
400
	
400
	
401
	mov	ecx,edi
401
	mov	ecx,edi
402
	pop	esi
402
	pop	esi
403
	sub	ecx,esi
403
	sub	ecx,esi
404
	inc	ecx		 ; length of filename
404
	inc	ecx		 ; length of filename
405
	mov	edi, fileinfo_start.name
405
	mov	edi, fileinfo_start.name
406
	rep	movsb		   ; copy string
406
	rep	movsb		   ; copy string
407
	mov	[edi],byte 0	       ; store terminator
407
	mov	[edi],byte 0	       ; store terminator
408
	mcall	70,fileinfo_start	; start program
408
	mcall	70,fileinfo_start	; start program
409
	or	[close_now],1      ; set close flag
409
	or	[close_now],1      ; set close flag
410
	pop	edi
410
	pop	edi
411
	mov	[mousemask],0
411
	mov	[mousemask],0
412
	jmp	close
412
	jmp	close
413
;--------------------------------------
413
;--------------------------------------
414
align 4
414
align 4
415
searchexit:
415
searchexit:
416
	pop	edi
416
	pop	edi
417
	jmp	still
417
	jmp	still
418
;------------------------------------------------------------------------------
418
;------------------------------------------------------------------------------
419
align 4
419
align 4
420
runthread:
420
runthread:
421
	inc	edi
421
	inc	edi
422
	
422
	
423
	push	eax
423
	push	eax
424
	call	get_number	     ; get number of this process
424
	call	get_number	     ; get number of this process
425
	pop	eax
425
	pop	eax
426
	
426
	
427
	test	ebx,ebx	   ; returned zero - main menu or not number
427
	test	ebx,ebx	   ; returned zero - main menu or not number
428
	jz	searchexit
428
	jz	searchexit
429
	
429
	
430
	mov	al,bl
430
	mov	al,bl
431
	
431
	
432
	mov	ebx,[processes]
432
	mov	ebx,[processes]
433
	dec	bl
433
	dec	bl
434
	cmp	al,bl
434
	cmp	al,bl
435
	ja	searchexit	       ; such process doesnt exist
435
	ja	searchexit	       ; such process doesnt exist
436
	cmp	al,[esi + child]
436
	cmp	al,[esi + child]
437
	je	searchexit	       ; such process already exists
437
	je	searchexit	       ; such process already exists
438
	
438
	
439
	mov	[esi + child],al    ; this is my child
439
	mov	[esi + child],al    ; this is my child
440
	mov	cx,[esi + x_start]
440
	mov	cx,[esi + x_start]
441
	add	cx,BTN_WIDTH+1	  ; new x_start in cx
441
	add	cx,BTN_WIDTH+1	  ; new x_start in cx
442
	movzx	edx,al
442
	movzx	edx,al
443
	shl	edx,4
443
	shl	edx,4
444
	add	edx,[menu_data]       ; edx points to child's base address
444
	add	edx,[menu_data]       ; edx points to child's base address
445
	mov	[edx + x_start],cx  ; xstart for new thread
445
	mov	[edx + x_start],cx  ; xstart for new thread
446
	mov	cx,[esi + y_end]   ; y_end in cx
446
	mov	cx,[esi + y_end]   ; y_end in cx
447
	mov	bl,[esi + rows]    ; number of buttons in bl
447
	mov	bl,[esi + rows]    ; number of buttons in bl
448
	sub	bl,ah	  ; number of btn from bottom
448
	sub	bl,ah	  ; number of btn from bottom
449
 
449
 
450
	; Leency: store vars for case when attachement=top 
450
	; Leency: store vars for case when attachement=top 
451
	pusha
451
	pusha
452
	mov [prior_thread_selected_y_end], bl
452
	mov [prior_thread_selected_y_end], bl
453
	mcall	9,procinfo,-1
453
	mcall	9,procinfo,-1
454
	m2m     [prior_thread_y], dword[procinfo+38]
454
	m2m     [prior_thread_y], dword[procinfo+38]
455
	m2m     [prior_thread_h], dword[procinfo+46]
455
	m2m     [prior_thread_h], dword[procinfo+46]
456
	popa
456
	popa
457
 
457
 
458
	movzx	eax,al
458
	movzx	eax,al
459
	mov	[buffer],eax		; thread id in buffer
459
	mov	[buffer],eax		; thread id in buffer
460
	movzx	ebx,bl
460
	movzx	ebx,bl
461
	push	edx
461
	push	edx
462
	mov	eax,BTN_HEIGHT
462
	mov	eax,BTN_HEIGHT
463
	mul	ebx
463
	mul	ebx
464
	sub	cx,ax	  ; new y_end for new thread
464
	sub	cx,ax	  ; new y_end for new thread
465
	pop	edx
465
	pop	edx
466
	mov	[edx + y_end],cx    ; store y_end
466
	mov	[edx + y_end],cx    ; store y_end
467
	mov	edi,esi
467
	mov	edi,esi
468
	call	backconvert	      ; get number of this process (al)
468
	call	backconvert	      ; get number of this process (al)
469
	mov	[edx + parent],al   ; store number of parent process
469
	mov	[edx + parent],al   ; store number of parent process
470
 
470
 
471
	mov	al,[edx + rows]
471
	mov	al,[edx + rows]
472
	mov	[edx + cur_sel],al  ; clear current selected element
472
	mov	[edx + cur_sel],al  ; clear current selected element
473
	mov	[edx + prev_sel],al ; clear previous selected element
473
	mov	[edx + prev_sel],al ; clear previous selected element
474
	mov	[edx + child],0
474
	mov	[edx + child],0
475
	
475
	
476
	mcall	68,12,0x1000	; stack of each thread is allocated 4 KB
476
	mcall	68,12,0x1000	; stack of each thread is allocated 4 KB
477
	add	eax,0x1000	; set the stack pointer to the desired position
477
	add	eax,0x1000	; set the stack pointer to the desired position
478
	mov	edx,eax
478
	mov	edx,eax
479
	mcall	51,1,thread	; Go ahead!
479
	mcall	51,1,thread	; Go ahead!
480
	jmp	searchexit
480
	jmp	searchexit
481
;------------------------------------------------------------------------------
481
;------------------------------------------------------------------------------
482
align 4
482
align 4
483
mouse: 	      ; MOUSE EVENT HANDLER
483
mouse: 	      ; MOUSE EVENT HANDLER
484
	mcall	37,0
484
	mcall	37,0
485
	mov	[screen_mouse_position],eax ; eax = [ Y | X ] relative to screen
485
	mov	[screen_mouse_position],eax ; eax = [ Y | X ] relative to screen
486
 
486
 
487
	mcall	37,2
487
	mcall	37,2
488
	test	eax,eax	   ; check buttons state
488
	test	eax,eax	   ; check buttons state
489
	jnz	click
489
	jnz	click
490
	mcall	37,1
490
	mcall	37,1
491
	ror	eax,16	  ; eax = [ Y | X ] relative to window
491
	ror	eax,16	  ; eax = [ Y | X ] relative to window
492
	cmp	ax,BTN_WIDTH	   ; pointer in window?
492
	cmp	ax,BTN_WIDTH	   ; pointer in window?
493
	ja	noinwindow
493
	ja	noinwindow
494
; *** in window ***
494
; *** in window ***
495
	shr	eax,16	  ; eax = [ 0 | Y ]
495
	shr	eax,16	  ; eax = [ 0 | Y ]
496
	xor	edx,edx
496
	xor	edx,edx
497
	mov	ebx,BTN_HEIGHT
497
	mov	ebx,BTN_HEIGHT
498
	div	ebx
498
	div	ebx
499
	inc	eax		  ; number of "button" in eax
499
	inc	eax		  ; number of "button" in eax
500
	movzx	ebx,[edi + rows]    ; total strings in ebx
500
	movzx	ebx,[edi + rows]    ; total strings in ebx
501
	cmp	eax,ebx
501
	cmp	eax,ebx
502
	ja	noinwindow
502
	ja	noinwindow
503
	cmp	[edi + cur_sel],al
503
	cmp	[edi + cur_sel],al
504
	je	noredrawbut
504
	je	noredrawbut
505
	mov	bl,[edi + cur_sel]
505
	mov	bl,[edi + cur_sel]
506
;;;;;;
506
;;;;;;
507
	cmp	[edi + child],0
507
	cmp	[edi + child],0
508
	jne	noredrawbut
508
	jne	noredrawbut
509
;;;;;;
509
;;;;;;
510
	mov	[edi + cur_sel],al
510
	mov	[edi + cur_sel],al
511
	mov	[edi + prev_sel],bl
511
	mov	[edi + prev_sel],bl
512
;--------------------------------------
512
;--------------------------------------
513
align 4
513
align 4
514
redrawbut:
514
redrawbut:
515
	call	draw_only_needed_buttons
515
	call	draw_only_needed_buttons
516
;--------------------------------------
516
;--------------------------------------
517
align 4
517
align 4
518
noredrawbut:
518
noredrawbut:
519
	call	backconvert
519
	call	backconvert
520
	bts	[mousemask],eax
520
	bts	[mousemask],eax
521
	jmp	still
521
	jmp	still
522
;--------------------------------------
522
;--------------------------------------
523
align 4
523
align 4
524
noinwindow:
524
noinwindow:
525
	call	backconvert
525
	call	backconvert
526
	btr	[mousemask],eax
526
	btr	[mousemask],eax
527
	jmp	still
527
	jmp	still
528
;------------------------------------------------------------------------------
528
;------------------------------------------------------------------------------
529
align 4
529
align 4
530
click:
530
click:
531
	cmp	[mousemask],0  ; not in a window (i.e. menu)
531
	cmp	[mousemask],0  ; not in a window (i.e. menu)
532
	jne	still
532
	jne	still
533
; checking for pressing 'MENU' on the taskbar	
533
; checking for pressing 'MENU' on the taskbar	
534
	mov	eax,[screen_mouse_position]
534
	mov	eax,[screen_mouse_position]
535
	
535
	
536
	cmp	[panel_attachment],byte 1
536
	cmp	[panel_attachment],byte 1
537
	je	@f
537
	je	@f
538
 
538
 
539
	xor	ebx,ebx
539
	xor	ebx,ebx
540
	jmp	.check_y
540
	jmp	.check_y
541
;--------------------------------------
541
;--------------------------------------
542
align 4
542
align 4
543
@@:
543
@@:
544
	mov	ebx,[screen_size]
544
	mov	ebx,[screen_size]
545
	sub	bx,word [panel_height]	;PANEL_HEIGHT
545
	sub	bx,word [panel_height]	;PANEL_HEIGHT
546
;--------------------------------------
546
;--------------------------------------
547
align 4
547
align 4
548
.check_y:
548
.check_y:
549
	add	bx,word [menu_button_y.start]
549
	add	bx,word [menu_button_y.start]
550
	cmp	bx,ax
550
	cmp	bx,ax
551
	ja	close
551
	ja	close
552
 
552
 
553
	add	bx,word [menu_button_y.size]
553
	add	bx,word [menu_button_y.size]
554
	cmp	bx,ax
554
	cmp	bx,ax
555
	jb	close
555
	jb	close
556
	
556
	
557
	shr	eax,16
557
	shr	eax,16
558
	
558
	
559
	mov	ebx,[menu_button_x.start]
559
	mov	ebx,[menu_button_x.start]
560
	cmp	bx,ax	; MENU_BOTTON_X_SIZE
560
	cmp	bx,ax	; MENU_BOTTON_X_SIZE
561
	ja	close
561
	ja	close
562
	
562
	
563
	add	bx,[menu_button_x.size]
563
	add	bx,[menu_button_x.size]
564
	cmp	bx,ax	; MENU_BOTTON_X_POS
564
	cmp	bx,ax	; MENU_BOTTON_X_POS
565
	ja	still
565
	ja	still
566
;------------------------------------------------------------------------------
566
;------------------------------------------------------------------------------
567
align 4
567
align 4
568
close:
568
close:
569
	
569
	
570
	movzx	ebx,[edi+parent]       ; parent id
570
	movzx	ebx,[edi+parent]       ; parent id
571
	shl	ebx,4
571
	shl	ebx,4
572
	add	ebx,[menu_data]          ; ebx = base of parent info
572
	add	ebx,[menu_data]          ; ebx = base of parent info
573
	call	backconvert
573
	call	backconvert
574
	cmp	[ebx + child],al       ; if i am the child of my parent...
574
	cmp	[ebx + child],al       ; if i am the child of my parent...
575
	jnz	@f
575
	jnz	@f
576
	mov	[ebx + child],-1       ; ...my parent now has no children
576
	mov	[ebx + child],-1       ; ...my parent now has no children
577
;--------------------------------------
577
;--------------------------------------
578
align 4
578
align 4
579
@@:
579
@@:
580
	or	eax,-1                 ; close this thread
580
	or	eax,-1                 ; close this thread
581
	mov	[edi + child],al       ; my child is not mine
581
	mov	[edi + child],al       ; my child is not mine
582
	
582
	
583
	call	free_area_if_set_mutex
583
	call	free_area_if_set_mutex
584
	call	set_mutex_for_free_area
584
	call	set_mutex_for_free_area
585
	
585
	
586
	mcall
586
	mcall
587
;--------------------------------------
587
;--------------------------------------
588
align 4
588
align 4
589
backconvert:		  ; convert from pointer to process id
589
backconvert:		  ; convert from pointer to process id
590
	mov	eax,edi
590
	mov	eax,edi
591
	sub	eax,[menu_data]
591
	sub	eax,[menu_data]
592
	shr	eax,4
592
	shr	eax,4
593
	ret
593
	ret
594
;------------------------------------------------------------------------------
594
;------------------------------------------------------------------------------
595
align 4
595
align 4
596
set_mutex_for_free_area:
596
set_mutex_for_free_area:
597
; set mutex for free thread stack area	
597
; set mutex for free thread stack area	
598
	push	eax ebx
598
	push	eax ebx
599
;--------------------------------------
599
;--------------------------------------
600
align 4
600
align 4
601
.wait_lock:
601
.wait_lock:
602
        cmp     [free_my_area_lock], 0
602
        cmp     [free_my_area_lock], 0
603
        je      .get_lock
603
        je      .get_lock
604
	mcall	68,1
604
	mcall	68,1
605
        jmp     .wait_lock
605
        jmp     .wait_lock
606
;--------------------------------------
606
;--------------------------------------
607
align 4
607
align 4
608
.get_lock:
608
.get_lock:
609
        mov     eax, 1
609
        mov     eax, 1
610
        xchg    eax, [free_my_area_lock]
610
        xchg    eax, [free_my_area_lock]
611
        test    eax, eax
611
        test    eax, eax
612
        jnz     .wait_lock
612
        jnz     .wait_lock
613
	mov	[free_my_area],ebp
613
	mov	[free_my_area],ebp
614
	pop	ebx eax
614
	pop	ebx eax
615
	ret
615
	ret
616
;------------------------------------------------------------------------------
616
;------------------------------------------------------------------------------
617
align 4
617
align 4
618
free_area_if_set_mutex:
618
free_area_if_set_mutex:
619
	cmp	[free_my_area_lock],0
619
	cmp	[free_my_area_lock],0
620
	je	.end
620
	je	.end
621
 
621
 
622
	push	eax ebx ecx
622
	push	eax ebx ecx
623
	mov	ecx,[free_my_area]
623
	mov	ecx,[free_my_area]
624
 
624
 
625
	test	ecx,ecx
625
	test	ecx,ecx
626
	jz	@f
626
	jz	@f
627
	mcall	68,13
627
	mcall	68,13
628
;--------------------------------------
628
;--------------------------------------
629
align 4
629
align 4
630
@@:
630
@@:
631
	xor	eax,eax
631
	xor	eax,eax
632
	mov	[free_my_area_lock],eax
632
	mov	[free_my_area_lock],eax
633
	pop	ecx ebx eax
633
	pop	ecx ebx eax
634
;--------------------------------------
634
;--------------------------------------
635
align 4
635
align 4
636
.end:	
636
.end:	
637
	ret
637
	ret
638
;------------------------------------------------------------------------------
638
;------------------------------------------------------------------------------
639
;==================================
639
;==================================
640
; get_number
640
; get_number
641
;    load number from [edi] to ebx
641
;    load number from [edi] to ebx
642
;==================================
642
;==================================
643
align 4
643
align 4
644
get_number:
644
get_number:
645
	push	edi
645
	push	edi
646
	xor	eax,eax
646
	xor	eax,eax
647
	xor	ebx,ebx
647
	xor	ebx,ebx
648
;--------------------------------------
648
;--------------------------------------
649
align 4
649
align 4
650
.get_next_char:
650
.get_next_char:
651
	mov	al,[edi]
651
	mov	al,[edi]
652
	inc	edi
652
	inc	edi
653
	cmp	al, '0'
653
	cmp	al, '0'
654
	jb	.finish
654
	jb	.finish
655
	cmp	al, '9'
655
	cmp	al, '9'
656
	ja	.finish
656
	ja	.finish
657
	sub	al, '0'
657
	sub	al, '0'
658
	imul	ebx,10
658
	imul	ebx,10
659
	add	ebx,eax
659
	add	ebx,eax
660
	jmp	.get_next_char
660
	jmp	.get_next_char
661
;-------------------------------------
661
;-------------------------------------
662
align 4
662
align 4
663
.finish:
663
.finish:
664
	pop	edi
664
	pop	edi
665
	ret
665
	ret
666
;------------------------------------------------------------------------------
666
;------------------------------------------------------------------------------
667
align 4
667
align 4
668
get_process_ID:
668
get_process_ID:
669
	mcall	9,procinfo,-1
669
	mcall	9,procinfo,-1
670
	mov	edx,eax
670
	mov	edx,eax
671
	mov	ecx,[ebx+30]	; PID
671
	mov	ecx,[ebx+30]	; PID
672
	ret
672
	ret
673
;------------------------------------------------------------------------------
673
;------------------------------------------------------------------------------
674
align 4
674
align 4
675
program_exist:
675
program_exist:
676
	call	get_process_ID
676
	call	get_process_ID
677
	mov	[main_process_ID],ecx
677
	mov	[main_process_ID],ecx
678
	mcall	18,21
678
	mcall	18,21
679
	mov	[active_process],eax	; WINDOW SLOT
679
	mov	[active_process],eax	; WINDOW SLOT
680
	mov	ecx,edx
680
	mov	ecx,edx
681
	xor	edx,edx
681
	xor	edx,edx
682
;-----------------------------------------
682
;-----------------------------------------
683
align 4
683
align 4
684
.loop:
684
.loop:
685
	push	ecx
685
	push	ecx
686
	mcall	9,procinfo
686
	mcall	9,procinfo
687
	mov	eax,[menu_mame]
687
	mov	eax,[menu_mame]
688
	cmp	[ebx+10],eax
688
	cmp	[ebx+10],eax
689
	jne	@f
689
	jne	@f
690
	; temporary to fit into 3 IMG sectors
690
	; temporary to fit into 3 IMG sectors
691
	;mov	ax,[menu_mame+4]
691
	;mov	ax,[menu_mame+4]
692
	;cmp	[ebx+14],ax
692
	;cmp	[ebx+14],ax
693
	;jne	@f
693
	;jne	@f
694
	cmp	ecx,[active_process]
694
	cmp	ecx,[active_process]
695
	je	@f
695
	je	@f
696
; dph ecx
696
; dph ecx
697
	mcall	18,2
697
	mcall	18,2
698
	mov	edx,1
698
	mov	edx,1
699
;--------------------------------------
699
;--------------------------------------
700
align 4
700
align 4
701
@@:
701
@@:
702
	pop	ecx
702
	pop	ecx
703
	loop	.loop
703
	loop	.loop
704
 
704
 
705
	test	edx,edx
705
	test	edx,edx
706
	jz	@f
706
	jz	@f
707
	mcall	-1
707
	mcall	-1
708
;--------------------------------------
708
;--------------------------------------
709
align 4
709
align 4
710
@@:
710
@@:
711
	ret
711
	ret
712
;------------------------------------------------------------------------------
712
;------------------------------------------------------------------------------
713
;   *********************************************
713
;   *********************************************
714
;   *******  WINDOW DEFINITIONS AND DRAW ********
714
;   *******  WINDOW DEFINITIONS AND DRAW ********
715
;   *********************************************
715
;   *********************************************
716
align 4
716
align 4
717
draw_window:
717
draw_window:
718
	mcall	48,5
718
	mcall	48,5
719
	mov	[x_working_area],eax
719
	mov	[x_working_area],eax
720
	mov	[y_working_area],ebx
720
	mov	[y_working_area],ebx
721
 
721
 
722
	mcall	12,1	; 1,start of draw
722
	mcall	12,1	; 1,start of draw
723
	movzx	ebx,[edi + rows]
723
	movzx	ebx,[edi + rows]
724
	imul	eax,ebx,BTN_HEIGHT	    ; eax = height of window
724
	imul	eax,ebx,BTN_HEIGHT	    ; eax = height of window
725
	movzx	ecx,[edi + y_end]
725
	movzx	ecx,[edi + y_end]
726
	cmp	[panel_attachment],byte 1
726
	cmp	[panel_attachment],byte 1
727
	je	@f
727
	je	@f
728
	
728
	
729
	
729
	
730
	;cmp	ebp,0x000 ; if this is first started thread
730
	;cmp	ebp,0x000 ; if this is first started thread
731
	;je .1            ; then show it at the very top
731
	;je .1            ; then show it at the very top
732
	
732
	
733
	push  ebx eax
733
	push  ebx eax
734
	; if attachement=top 
734
	; if attachement=top 
735
	; then NEW_WIN_Y = PRIOR_WIN_Y + PRIOR_WIN_H - ITEM_H + 1 - SEL_ITEM_Y
735
	; then NEW_WIN_Y = PRIOR_WIN_Y + PRIOR_WIN_H - ITEM_H + 1 - SEL_ITEM_Y
736
 
736
 
737
	mov ecx, [prior_thread_y]
737
	mov ecx, [prior_thread_y]
738
	add ecx, [prior_thread_h]
738
	add ecx, [prior_thread_h]
739
	sub ecx, BTN_HEIGHT
739
	sub ecx, BTN_HEIGHT
740
	inc ecx
740
	inc ecx
741
 
741
 
742
	xor eax, eax
742
	xor eax, eax
743
	mov al, [prior_thread_selected_y_end]
743
	mov al, [prior_thread_selected_y_end]
744
	mov ebx, BTN_HEIGHT
744
	mov ebx, BTN_HEIGHT
745
	mul ebx
745
	mul ebx
746
		
746
		
747
	sub ecx, eax
747
	sub ecx, eax
748
 
748
 
749
	mov	[edi + cur_sel],1 ;if attachement=top then set item=1 selected
749
	mov	[edi + cur_sel],1 ;if attachement=top then set item=1 selected
750
	
750
	
751
	pop eax ebx
751
	pop eax ebx
752
 
752
 
753
	jmp	.1
753
	jmp	.1
754
;--------------------------------------
754
;--------------------------------------
755
align 4
755
align 4
756
@@:	
756
@@:	
757
	sub	ecx,eax	    ; ecx = Y_START
757
	sub	ecx,eax	    ; ecx = Y_START
758
;--------------------------------------
758
;--------------------------------------
759
align 4
759
align 4
760
.1:
760
.1:
761
	shl	ecx,16
761
	shl	ecx,16
762
	add	ecx,eax	    ; ecx = [ Y_START | Y_SIZE ]
762
	add	ecx,eax	    ; ecx = [ Y_START | Y_SIZE ]
763
	dec ecx
763
	dec ecx
764
 
764
 
765
	movzx	ebx,[edi + x_start]
765
	movzx	ebx,[edi + x_start]
766
	shl	ebx,16
766
	shl	ebx,16
767
	mov	bx,BTN_WIDTH	    ; ebx = [ X_START | X_SIZE ]
767
	mov	bx,BTN_WIDTH	    ; ebx = [ X_START | X_SIZE ]
768
	mov	edx,0x01000000       ; color of work area RRGGBB,8->color gl
768
	mov	edx,0x01000000       ; color of work area RRGGBB,8->color gl
769
	mov	esi,edx	    ; unmovable window
769
	mov	esi,edx	    ; unmovable window
770
	
770
	
771
	mov	eax,[y_working_area]
771
	mov	eax,[y_working_area]
772
	shr	eax,16
772
	shr	eax,16
773
	ror	ecx,16
773
	ror	ecx,16
774
	test	cx,0x8000
774
	test	cx,0x8000
775
	jz	@f
775
	jz	@f
776
	mov	cx,ax
776
	mov	cx,ax
777
;--------------------------------------
777
;--------------------------------------
778
align 4
778
align 4
779
@@:
779
@@:
780
	cmp	cx,ax
780
	cmp	cx,ax
781
	ja	@f
781
	ja	@f
782
	mov	cx,ax	
782
	mov	cx,ax	
783
;--------------------------------------
783
;--------------------------------------
784
align 4
784
align 4
785
@@:
785
@@:
786
	rol	ecx,16
786
	rol	ecx,16
787
	xor	eax,eax	    ; function 0 : define and draw window
787
	xor	eax,eax	    ; function 0 : define and draw window
788
	mcall
788
	mcall
789
	
789
	
790
;	dps	"[ Y_START | Y_SIZE ] : "
790
;	dps	"[ Y_START | Y_SIZE ] : "
791
;	dph	ecx
791
;	dph	ecx
792
;	newline
792
;	newline
793
 
793
 
794
;	dps	"[ X_START | X_SIZE ] : "
794
;	dps	"[ X_START | X_SIZE ] : "
795
;	dph	ebx
795
;	dph	ebx
796
;	newline
796
;	newline
797
 
797
 
798
	call	draw_all_buttons
798
	call	draw_all_buttons
799
	mcall	12,2
799
	mcall	12,2
800
	ret
800
	ret
801
;------------------------------------------------------------------------------
801
;------------------------------------------------------------------------------
802
align 4
802
align 4
803
draw_all_buttons:
803
draw_all_buttons:
804
	xor	edx,edx
804
	xor	edx,edx
805
;--------------------------------------
805
;--------------------------------------
806
align 4
806
align 4
807
.new_button:
807
.new_button:
808
	call	draw_one_button
808
	call	draw_one_button
809
	inc	edx
809
	inc	edx
810
	cmp	dl,[edi + rows]
810
	cmp	dl,[edi + rows]
811
	jb	.new_button
811
	jb	.new_button
812
	ret
812
	ret
813
;------------------------------------------------------------------------------
813
;------------------------------------------------------------------------------
814
align 4
814
align 4
815
draw_only_needed_buttons:
815
draw_only_needed_buttons:
816
	xor	edx,edx
816
	xor	edx,edx
817
	mov	dl,[edi + cur_sel]
817
	mov	dl,[edi + cur_sel]
818
	dec	dl
818
	dec	dl
819
	call	draw_one_button
819
	call	draw_one_button
820
	mov	dl,[edi + prev_sel]
820
	mov	dl,[edi + prev_sel]
821
	dec	dl
821
	dec	dl
822
	call	draw_one_button
822
	call	draw_one_button
823
	ret
823
	ret
824
;------------------------------------------------------------------------------
824
;------------------------------------------------------------------------------
825
align 4
825
align 4
826
draw_one_button:
826
draw_one_button:
827
; receives number of button in dl
827
; receives number of button in dl
828
	push	edx
828
	push	edx
829
	mov	eax,8
829
	mov	eax,8
830
	mov	ebx,BTN_WIDTH
830
	mov	ebx,BTN_WIDTH
831
	movzx	ecx,dl
831
	movzx	ecx,dl
832
	imul	ecx,BTN_HEIGHT
832
	imul	ecx,BTN_HEIGHT
833
	mov [draw_y], ecx
833
	mov [draw_y], ecx
834
	shl	ecx,16
834
	shl	ecx,16
835
	add	ecx,BTN_HEIGHT
835
	add	ecx,BTN_HEIGHT
836
; edx = button identifier
836
; edx = button identifier
837
	mov	esi,[sc.work]
837
	mov	esi,[sc.work]
838
	cmp	esi,0xdfdfdf
838
	cmp	esi,0xdfdfdf
839
	jb	nocorrect
839
	jb	nocorrect
840
	sub	esi,0x1b1b1b
840
	sub	esi,0x1b1b1b
841
	
841
	
842
;--------------------------------------
842
;--------------------------------------
843
align 4
843
align 4
844
nocorrect: 
844
nocorrect: 
845
	inc	dl
845
	inc	dl
846
	cmp	[edi + cur_sel],dl
846
	cmp	[edi + cur_sel],dl
847
	jne	.nohighlight
847
	jne	.nohighlight
848
	cmp esi,0
848
	cmp esi,0
849
	jne @f
849
	jne @f
850
	mov esi,0x2a2a2a
850
	mov esi,0x2a2a2a
851
@@:
851
@@:
852
	add	esi,0x1a1a1a
852
	add	esi,0x1a1a1a
853
;--------------------------------------
853
;--------------------------------------
854
align 4
854
align 4
855
.nohighlight:
855
.nohighlight:
856
	or	edx,BT_NOFRAME + BT_HIDE
856
	or	edx,BT_NOFRAME + BT_HIDE
857
				; dunkaist[
857
				; dunkaist[
858
	add	edx,0xd1ff00	; This makes first menu buttons differ
858
	add	edx,0xd1ff00	; This makes first menu buttons differ
859
				; from system close button with 0x000001 id
859
				; from system close button with 0x000001 id
860
				; dunkaist]
860
				; dunkaist]
861
	mcall
861
	mcall
862
	push edx 
862
	push edx 
863
	
863
	
864
	mov edx, esi
864
	mov edx, esi
865
	mcall 13
865
	mcall 13
866
	
866
	
867
	mcall , BTN_WIDTH,<[draw_y],1>,[sc.work_light]
867
	mcall , BTN_WIDTH,<[draw_y],1>,[sc.work_light]
868
	add     ecx, BTN_HEIGHT-1
868
	add     ecx, BTN_HEIGHT-1
869
	mcall , 1
869
	mcall , 1
870
	inc     ecx
870
	inc     ecx
871
	mcall , , , [sc.work_dark]
871
	mcall , , , [sc.work_dark]
872
	add     [draw_y], BTN_HEIGHT-1
872
	add     [draw_y], BTN_HEIGHT-1
873
	mcall , BTN_WIDTH,<[draw_y],1>
873
	mcall , BTN_WIDTH,<[draw_y],1>
874
	
874
	
875
	pop edx
875
	pop edx
876
	movzx	edx,dl
876
	movzx	edx,dl
877
	dec	dl
877
	dec	dl
878
	imul	ebx,edx,BTN_HEIGHT
878
	imul	ebx,edx,BTN_HEIGHT
879
	add	ebx,(4 shl 16) + TXT_Y
879
	add	ebx,(4 shl 16) + TXT_Y
880
	movzx	ecx,dl
880
	movzx	ecx,dl
881
	inc	ecx
881
	inc	ecx
882
	mov	edx,[edi + pointer]
882
	mov	edx,[edi + pointer]
883
;--------------------------------------
883
;--------------------------------------
884
align 4
884
align 4
885
.findline:
885
.findline:
886
	cmp	byte [edx],13
886
	cmp	byte [edx],13
887
	je	.linefound
887
	je	.linefound
888
	inc	edx
888
	inc	edx
889
	jmp	.findline
889
	jmp	.findline
890
;------------------------------------------------------------------------------
890
;------------------------------------------------------------------------------
891
align 4
891
align 4
892
.linefound:
892
.linefound:
893
	inc	edx
893
	inc	edx
894
	cmp	byte [edx],10
894
	cmp	byte [edx],10
895
	jne	.findline
895
	jne	.findline
896
	dec	ecx
896
	dec	ecx
897
	jnz	.findline
897
	jnz	.findline
898
	
898
	
-
 
899
	mov ecx, [sc.work_text]
-
 
900
	add ecx, FONT_TYPE
899
	mcall	4,,[sc.work_text],,21
901
	mcall	4,,,,21
900
	pop	edx
902
	pop	edx
901
	ret
903
	ret
902
;------------------------------------------------------------------------------
904
;------------------------------------------------------------------------------
903
align 4
905
align 4
904
searchstartstring:
906
searchstartstring:
905
	mov	ecx,40
907
	mov	ecx,40
906
	mov	al,13
908
	mov	al,13
907
	cld
909
	cld
908
	repne	scasb
910
	repne	scasb
909
	cmp	byte [edi],10
911
	cmp	byte [edi],10
910
	jne	searchstartstring
912
	jne	searchstartstring
911
	ret
913
	ret
912
;------------------------------------------------------------------------------
914
;------------------------------------------------------------------------------
913
;*** DATA AREA ****************************************************************
915
;*** DATA AREA ****************************************************************
914
menu_mame:   db '@MENU',0
916
menu_mame:   db '@MENU',0
915
default_dir: db '/sys',0
917
default_dir: db '/sys',0
916
 
918
 
917
align 4
919
align 4
918
free_my_area_lock	dd 0
920
free_my_area_lock	dd 0
919
free_my_area	dd 0
921
free_my_area	dd 0
920
 
922
 
921
processes      dd 0
923
processes      dd 0
922
;--------------------------------------
924
;--------------------------------------
923
menu_button_x:
925
menu_button_x:
924
.start:	dd MENU_BOTTON_X_POS
926
.start:	dd MENU_BOTTON_X_POS
925
.size:	dd MENU_BOTTON_X_SIZE
927
.size:	dd MENU_BOTTON_X_SIZE
926
;--------------------------------------
928
;--------------------------------------
927
menu_button_y:
929
menu_button_y:
928
.start:	dd 2
930
.start:	dd 2
929
.size:	dd 18
931
.size:	dd 18
930
;--------------------------------------
932
;--------------------------------------
931
panel_height:		dd PANEL_HEIGHT
933
panel_height:		dd PANEL_HEIGHT
932
panel_attachment:	dd 1
934
panel_attachment:	dd 1
933
;--------------------------------------
935
;--------------------------------------
934
align 4
936
align 4
935
fileinfo:
937
fileinfo:
936
 .subfunction	 dd 5		; 5 - file info; 0 - file read
938
 .subfunction	 dd 5		; 5 - file info; 0 - file read
937
 .start 	 dd 0		; start byte
939
 .start 	 dd 0		; start byte
938
 .size_high	 dd 0		; rezerved
940
 .size_high	 dd 0		; rezerved
939
 .size		 dd 0		; bytes to read
941
 .size		 dd 0		; bytes to read
940
 .return	 dd procinfo	; return data pointer
942
 .return	 dd procinfo	; return data pointer
941
 .name:
943
 .name:
942
     db   'SETTINGS/MENU.DAT',0   ; ASCIIZ dir & filename
944
     db   'SETTINGS/MENU.DAT',0   ; ASCIIZ dir & filename
943
;--------------------------------------
945
;--------------------------------------
944
align 4
946
align 4
945
fileinfo_start:
947
fileinfo_start:
946
 .subfunction	dd 7	; 7=START APPLICATION
948
 .subfunction	dd 7	; 7=START APPLICATION
947
 .flags		dd 0	; flags
949
 .flags		dd 0	; flags
948
 .params	dd 0x0	; nop
950
 .params	dd 0x0	; nop
949
 .rezerved	dd 0x0	; nop
951
 .rezerved	dd 0x0	; nop
950
 .rezerved_1	dd 0x0	; nop
952
 .rezerved_1	dd 0x0	; nop
951
 .name:
953
 .name:
952
   times 50 db ' '
954
   times 50 db ' '
953
;------------------------------------------------------------------------------
955
;------------------------------------------------------------------------------
954
IM_END:
956
IM_END:
955
;------------------------------------------------------------------------------
957
;------------------------------------------------------------------------------
956
align 4
958
align 4
957
close_now	dd ?   ; close all processes immediately
959
close_now	dd ?   ; close all processes immediately
958
end_pointer	dd ?
960
end_pointer	dd ?
959
buffer		dd ?
961
buffer		dd ?
960
mousemask	dd ?   ; mask for mouse pointer location
962
mousemask	dd ?   ; mask for mouse pointer location
961
 
963
 
962
active_process	dd ?
964
active_process	dd ?
963
main_process_ID	dd ?
965
main_process_ID	dd ?
964
;--------------------------------------
966
;--------------------------------------
965
screen_mouse_position:
967
screen_mouse_position:
966
.y	dw ?
968
.y	dw ?
967
.x	dw ?
969
.x	dw ?
968
;--------------------------------------
970
;--------------------------------------
969
screen_size:
971
screen_size:
970
.y	dw ?
972
.y	dw ?
971
.x	dw ?
973
.x	dw ?
972
;--------------------------------------
974
;--------------------------------------
973
draw_y dd ?
975
draw_y dd ?
974
;--------------------------------------
976
;--------------------------------------
975
x_working_area:
977
x_working_area:
976
.right:		dw ?
978
.right:		dw ?
977
.left:		dw ?
979
.left:		dw ?
978
y_working_area:
980
y_working_area:
979
.bottom:	dw ?
981
.bottom:	dw ?
980
.top:		dw ?
982
.top:		dw ?
981
;--------------------------------------
983
;--------------------------------------
982
sc system_colors
984
sc system_colors
983
;--------------------------------------
985
;--------------------------------------
984
last_key	db ?
986
last_key	db ?
985
prior_thread_y dd ?
987
prior_thread_y dd ?
986
prior_thread_h dd ?
988
prior_thread_h dd ?
987
prior_thread_selected_y_end db ?
989
prior_thread_selected_y_end db ?
988
;------------------------------------------------------------------------------
990
;------------------------------------------------------------------------------
989
align 4
991
align 4
990
menu_data   dd ?
992
menu_data   dd ?
991
;--------------------------------------
993
;--------------------------------------
992
virtual     at 0       ; PROCESSES TABLE (located at menu_data)
994
virtual     at 0       ; PROCESSES TABLE (located at menu_data)
993
  pointer   dd ?   ; +0    pointer in file
995
  pointer   dd ?   ; +0    pointer in file
994
  rows      db ?   ; +4    numer of strings
996
  rows      db ?   ; +4    numer of strings
995
  x_start   dw ?   ; +5    x start
997
  x_start   dw ?   ; +5    x start
996
  y_end     dw ?   ; +7    y end
998
  y_end     dw ?   ; +7    y end
997
  child     db ?   ; +9    id of child menu
999
  child     db ?   ; +9    id of child menu
998
  parent    db ?   ; +10   id of parent menu
1000
  parent    db ?   ; +10   id of parent menu
999
  cur_sel   db ?   ; +11   current selection
1001
  cur_sel   db ?   ; +11   current selection
1000
  prev_sel  db ?   ; +12   previous selection
1002
  prev_sel  db ?   ; +12   previous selection
1001
  rb        16-$+1 ; [16 bytes per element]
1003
  rb        16-$+1 ; [16 bytes per element]
1002
end virtual
1004
end virtual
1003
;------------------------------------------------------------------------------
1005
;------------------------------------------------------------------------------
1004
align 4
1006
align 4
1005
bootparam:
1007
bootparam:
1006
procinfo:
1008
procinfo:
1007
	rb 1024
1009
	rb 1024
1008
;------------------------------------------------------------------------------
1010
;------------------------------------------------------------------------------
1009
align 4
1011
align 4
1010
	rb 0x1000
1012
	rb 0x1000
1011
stack_area:
1013
stack_area:
1012
;------------------------------------------------------------------------------
1014
;------------------------------------------------------------------------------
1013
mem_end:
1015
mem_end:
1014
;------------------------------------------------------------------------------
1016
;------------------------------------------------------------------------------