Subversion Repositories Kolibri OS

Rev

Rev 1754 | Rev 2618 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1754 Rev 2211
Line 1... Line 1...
1
;******************************************************************************
1
;******************************************************************************
-
 
2
;   MAIN MENU
-
 
3
;******************************************************************************
-
 
4
; last update:  19/09/2011
-
 
5
; changed by:   Marat Zakiyanov aka Mario79, aka Mario
-
 
6
; changes:      Checking for program exist to memory
-
 
7
;               Added processing of keys: left and right arrow
-
 
8
;---------------------------------------------------------------------
2
;   MAIN MENU by lisovin@26.ru
9
;   MAIN MENU by lisovin@26.ru
3
;   Some parts of code rewritten by Ivan Poddubny 
10
;   Some parts of code rewritten by Ivan Poddubny 
4
;
11
;
5
;   Compile with FASM for Menuet
12
;   Compile with FASM for Menuet
6
;******************************************************************************
13
;******************************************************************************
Line 8... Line 15...
8
  include "..\..\..\macros.inc"
15
  include "..\..\..\macros.inc"
Line 9... Line 16...
9
 
16
 
10
  BTN_HEIGHT  = 22
17
  BTN_HEIGHT  = 22
Line -... Line 18...
-
 
18
  TXT_Y       = (BTN_HEIGHT)/2-5
-
 
19
 
-
 
20
  PANEL_HEIGHT	= 20
-
 
21
  MENU_BOTTON_X_POS	= 10
11
  TXT_Y       = (BTN_HEIGHT)/2-5
22
  MENU_BOTTON_X_SIZE	= 60
12
 
23
  
13
  use32
24
	use32
14
  org	  0x0
25
	org 0x0
15
  db	 'MENUET01'	    ; 8 byte id
26
	db 'MENUET01'	; 8 byte id
16
  dd	 0x01		  ; header version
27
	dd 0x01		; header version
17
  dd	 START		   ; start of code
28
	dd START	; start of code
18
  dd	 I_END		   ; size of image
29
	dd I_END	; size of image
19
  dd	 0x20000	 ; memory for app
30
	dd 0x20000	; memory for app
20
  dd	 0x20000-1	     ; esp
31
	dd 0x20000	; esp
21
  dd	 0x0 , 0x0	   ; I_Param , I_Icon
32
	dd 0x0,0x0	; I_Param , I_Icon
22
;******************************************************************************
33
;******************************************************************************
-
 
34
;include "DEBUG.INC"             ; debug macros
-
 
35
START:		       ; start of execution
-
 
36
	call	program_exist
Line 23... Line 37...
23
;include "DEBUG.INC"             ; debug macros
37
	mcall	14
24
START:		       ; start of execution
-
 
25
 
-
 
26
     mov  eax, 48	  ; load system colors
-
 
27
     mov  ebx, 3
-
 
28
     mov  ecx, sc
-
 
29
     mov  edx, sizeof.system_colors
38
	mov	[screen_size],eax
30
     mcall
-
 
31
 
-
 
32
     mov  eax, 70	  ; load MENU.DAT
39
	
33
     mov  ebx, fileinfo
40
	mcall	48,3,sc,sizeof.system_colors	; load system colors
34
     mcall
41
	mcall	70,fileinfo	; load MENU.DAT
35
     test eax, eax	   ; error ?
42
	test	eax,eax	   ; error ?
36
     jz  @f
43
	jz	@f
Line 56... Line 63...
56
     shl  ebx, 4
63
	shl	ebx,4
57
     add  ebx, menu_data     ; pointer to process table
64
	add	ebx,menu_data     ; pointer to process table
58
     mov  [ebx], edi
65
	mov	[ebx],edi
59
     inc  [processes]
66
	inc	[processes]
60
     jmp  newsearch
67
	jmp	newsearch
-
 
68
;---------------------------------------------------------------------
61
  search_end:
69
search_end:
62
     mov  [end_pointer], edi
70
	mov	[end_pointer],edi
63
     mov  ebx, [processes]
71
	mov	ebx,[processes]
64
     dec  ebx
72
	dec	ebx
65
     shl  ebx, 4
73
	shl	ebx,4
Line 76... Line 84...
76
     je   endprocess
84
	je	endprocess
77
     cmp  [edi], byte 13
85
	cmp	[edi],byte 13
78
     jne  newsearch1
86
	jne	newsearch1
79
     inc  edx
87
	inc	edx
80
     jmp  newsearch1
88
	jmp	newsearch1
-
 
89
;---------------------------------------------------------------------
81
  endprocess:
90
endprocess:
82
     mov  esi, ebx
91
	mov	esi,ebx
83
     add  esi, 4
92
	add	esi,4
84
     dec  edx
93
	dec	edx
85
     mov  [esi], dl
94
	mov	[esi],dl
86
     cmp  ebx, menu_data
95
	cmp	ebx,menu_data
87
     jbe  search_end1
96
	jbe	search_end1
88
     sub  ebx, 16
97
	sub	ebx,16
89
     jmp  newprocess
98
	jmp	newprocess
-
 
99
;---------------------------------------------------------------------
90
  search_end1:
100
search_end1:
91
     mov  eax, 14
-
 
92
     mcall
101
	mcall	14
93
     sub  ax, 20
102
	sub	ax,20
94
     mov  [menu_data + y_end],	    ax
103
	mov	[menu_data + y_end],ax
95
     mov  [menu_data + x_start],  5
104
	mov	[menu_data + x_start],5
96
     mov  al, [menu_data + rows]
105
	mov	al,[menu_data + rows]
97
     mov  [menu_data + cur_sel],  al	 ; clear selection
106
	mov	[menu_data + cur_sel],al	 ; clear selection
98
     mov  [menu_data + prev_sel], al
107
	mov	[menu_data + prev_sel],al
99
 
-
 
100
     mov  [buffer], 0
108
	mov	[buffer],0
101
  thread:
109
thread:
102
     mov  eax, [buffer]      ; identifier
110
	mov	eax,[buffer]      ; identifier
103
     shl  eax, 4
111
	shl	eax,4
104
     add  eax, menu_data
112
	add	eax,menu_data
105
     mov  edi, eax
113
	mov	edi,eax
106
 
-
 
107
     mov  eax, 40	  ; set event mask
-
 
108
     mov  ebx, 100111b	       ; mouse + button + key + redraw
114
	mcall	40,100111b	; mouse + button + key + redraw
109
     mcall
-
 
110
 
115
red:	
111
     call draw_window
116
	call	draw_window	; redraw
112
 
-
 
113
still:
117
still:
114
    mov  eax, 23	 ; wait here for event
118
	mcall	23,5	; wait here for event
115
    mov  ebx, 5
-
 
116
    mcall
-
 
117
 
-
 
118
    test [close_now], 1      ; is close flag set?
119
	test	[close_now],1      ; is close flag set?
119
    jnz  close
120
	jnz	close
Line 120... Line 121...
120
 
121
	
121
    cmp  eax, 1 	 ; redraw request ?
122
	cmp	eax,1	; redraw request ?
Line 124... Line 125...
124
    je	   key
125
	je	key
125
    cmp  eax, 3 	 ; button in buffer ?
126
	cmp	eax,3	; button in buffer ?
126
    je	   button
127
	je	button
127
    cmp  eax, 6 	 ; mouse event ?
128
	cmp	eax,6	; mouse event ?
128
    je	   mouse
129
	je	mouse
129
 
-
 
130
    cmp  edi, menu_data
130
	cmp	edi,menu_data
131
    je	   still	     ; if main process-ignored
131
	je	still	     ; if main process-ignored
Line 132... Line 132...
132
 
132
	
133
  movzx  ebx, [edi + parent]	 ; parent id
133
	movzx	ebx,[edi + parent]	 ; parent id
Line 136... Line 136...
136
    call backconvert	     ; get my id in al
136
	call	backconvert	     ; get my id in al
137
    cmp  al, [ebx + child]    ; if I'm not child of my parent, I shall die :)
137
	cmp	al,[ebx + child]    ; if I'm not child of my parent, I shall die :)
138
    jne  close
138
	jne	close
Line 139... Line 139...
139
 
139
	
140
    jmp  still
-
 
141
 
-
 
142
 
140
	jmp	still
143
  red:		       ; redraw
-
 
144
    call draw_window
-
 
145
    jmp  still
-
 
146
 
-
 
147
 
141
;---------------------------------------------------------------------
148
  key:
142
key:
149
;   mov  eax, 2
143
;	mov	eax,2
150
    mcall
-
 
-
 
144
	mcall
151
 
145
	mov	[last_key],ah
152
    mov  al,  [edi + rows]     ; number of buttons
-
 
153
 
146
	mov	al,[edi + rows]     ; number of buttons
154
    cmp  ah,  178	  ; KEY_UP
147
	cmp	ah,178	  ; KEY_UP
Line 155... Line 148...
155
    jne  .noup
148
	jne	.noup
156
 
149
	
157
    mov  ah,  [edi+cur_sel]
150
	mov	ah,[edi+cur_sel]
158
    mov  [edi+prev_sel], ah
151
	mov	[edi+prev_sel],ah
159
    dec  byte [edi+cur_sel]
152
	dec	byte [edi+cur_sel]
160
    jnz  redrawbut
153
	jnz	redrawbut
161
    mov  [edi+cur_sel], al
-
 
162
    jmp  redrawbut
-
 
-
 
154
	mov	[edi+cur_sel],al
163
 
155
	jmp	redrawbut
164
 
156
;---------------------------------------------------------------------
165
  .noup:
157
.noup:
Line 166... Line 158...
166
    cmp  ah, 177	 ; KEY_DOWN
158
	cmp	ah,177	 ; KEY_DOWN
Line 171... Line 163...
171
    inc  [edi + cur_sel]
163
	inc	[edi + cur_sel]
172
    cmp  [edi + cur_sel], al
164
	cmp	[edi + cur_sel],al
173
    jna  redrawbut
165
	jna	redrawbut
174
    mov  [edi + cur_sel], 1
166
	mov	[edi + cur_sel],1
175
    jmp  redrawbut
167
	jmp	redrawbut
176
 
-
 
-
 
168
;---------------------------------------------------------------------
177
  .nodn:
169
.nodn:
-
 
170
	cmp	ah,179 	 ; KEY_LEFT
-
 
171
	je	@f
178
    cmp  ah, 13 	 ; ENTER
172
	cmp	ah,13 	 ; ENTER
179
    jne  .noenter
173
	jne	.noenter
-
 
174
@@:
180
    mov  ah, [edi + cur_sel]
175
	mov	ah,[edi + cur_sel]
181
    jmp  button1
176
	jmp	button1
182
 
-
 
-
 
177
;---------------------------------------------------------------------
183
  .noenter:
178
.noenter:
-
 
179
	cmp	ah,176 	 ; KEY_RIGHT
-
 
180
	je	@f
184
    cmp  ah, 27 	 ; ESC
181
	cmp	ah,27 	 ; ESC
185
    jne  still
182
	jne	still
186
    jmp  close
183
	jmp	close
187
 
184
@@:
-
 
185
	call	get_process_ID
-
 
186
	cmp	[main_process_ID],ecx
-
 
187
	jne	close
-
 
188
	jmp	still
-
 
189
;---------------------------------------------------------------------
188
;           include "DEBUG.INC"
190
; include "DEBUG.INC"
189
 
-
 
190
  button:	      ; BUTTON HANDLER
191
button:	; BUTTON HANDLER
191
    mov  eax, 17	 ; get id
192
	mcall	17	; get id
192
    mcall
-
 
193
                        ; dunkaist[
193
				; dunkaist[
194
    test eax,0xfffffe00 ; is it system close button? (close signal from @panel)
194
	test	eax,0xfffffe00	; is it system close button? (close signal from @panel)
195
    setz byte[close_now]; set (or not set) close_recursive flag
195
	setz	byte[close_now]	; set (or not set) close_recursive flag
196
     jz  close          ; if so, close all menus
196
	jz	close		; if so,close all menus
197
                        ; dunkaist]
197
				; dunkaist]
198
  button1:
198
button1:
199
    mov  esi, edi
199
	mov	esi,edi
200
    push edi
200
	push	edi
201
    mov  edi, [edi + pointer]
201
	mov	edi,[edi + pointer]
202
 
-
 
203
; print "hello"
202
; print "hello"
204
    mov  al, [esi + cur_sel]
203
	mov	al,[esi + cur_sel]
205
    mov  [esi + prev_sel], al
204
	mov	[esi + prev_sel],al
206
    mov  [esi + cur_sel], ah
205
	mov	[esi + cur_sel],ah
-
 
206
	
207
    pushad
207
	pushad
208
    mov edi, esi
208
	mov	edi,esi
209
;    dph eax
209
; dph eax
210
    call draw_only_needed_buttons
210
	call	draw_only_needed_buttons
211
    popad
211
	popad
212
 
-
 
213
    ; look for the next line  times;  = button_id
212
; look for the next line  times;  = button_id
214
    push eax
213
	push	eax
215
  .next_string:
214
.next_string:
216
    call searchstartstring
215
	call	searchstartstring
217
    dec  ah
216
	dec	ah
Line 226... Line 225...
226
    je	   searchexit
225
	je	searchexit
Line 227... Line 226...
227
 
226
	
228
    cmp  [edi], byte '@'     ; check for submenu
227
	cmp	[edi],byte '@'     ; check for submenu
Line -... Line 228...
-
 
228
	je	runthread
-
 
229
	
-
 
230
	cmp	[last_key],179
229
    je	   runthread
231
	je	searchexit
230
 
232
	
231
    dec  edi
233
	dec	edi
232
    push edi		 ; pointer to start of filename
234
	push	edi			; pointer to start of filename
Line 237... Line 239...
237
    pop  esi
239
	pop	esi
238
    sub  ecx, esi
240
	sub	ecx,esi
239
    inc  ecx		 ; length of filename
241
	inc	ecx		 ; length of filename
240
    mov  edi, fileinfo_start.name
242
	mov	edi, fileinfo_start.name
241
    rep  movsb		   ; copy string
243
	rep	movsb		   ; copy string
242
    mov  byte [edi], 0	       ; store terminator
244
	mov	[edi],byte 0	       ; store terminator
243
    mov  eax, 70	 ; start program
245
	mcall	70,fileinfo_start	; start program
244
    mov  ebx, fileinfo_start
-
 
245
    mcall
-
 
246
;    mcall 5,100
-
 
247
    or	   [close_now], 1      ; set close flag
246
	or	[close_now],1      ; set close flag
248
    pop  edi
247
	pop	edi
249
    mov  [mousemask], 0
248
	mov	[mousemask],0
250
    jmp  close
249
	jmp	close
251
 
-
 
-
 
250
;---------------------------------------------------------------------
252
  searchexit:
251
searchexit:
253
    pop  edi
252
	pop	edi
254
    jmp  still
253
	jmp	still
255
 
-
 
256
 
-
 
-
 
254
;---------------------------------------------------------------------
257
  runthread:
255
runthread:
258
    inc  edi
256
	inc	edi
Line 259... Line 257...
259
 
257
	
260
    push eax
258
	push	eax
Line 301... Line 299...
301
    mov  [edx + child], 0
299
	mov	[edx + child],0
Line 302... Line 300...
302
 
300
	
303
    cmp  [thread_stack], 0x1e000
301
	cmp	[thread_stack],0x1e000
304
    jne  thread_stack_not_full
302
	jne	thread_stack_not_full
305
    mov  [thread_stack], 0xE000
-
 
306
 
303
	mov	[thread_stack],0xE000
307
thread_stack_not_full:
304
thread_stack_not_full:
308
    add  [thread_stack], 0x2000 ; start new thread
-
 
309
    mov  eax, 51
-
 
310
    mov  ebx, 1
-
 
311
    mov  ecx, thread
305
	add	[thread_stack],0x2000 ; start new thread
312
    mov  edx, [thread_stack]
-
 
313
    mcall
-
 
314
 
306
	mcall	51,1,thread,[thread_stack]
315
    jmp  searchexit
-
 
316
 
-
 
-
 
307
	jmp	searchexit
317
 
308
;---------------------------------------------------------------------
318
 mouse: 	      ; MOUSE EVENT HANDLER
309
mouse: 	      ; MOUSE EVENT HANDLER
319
    mov  eax, 37
310
	mcall	37,0
-
 
311
	mov	[screen_mouse_position],eax ; eax = [ Y | X ] relative to screen
320
    mov  ebx, 2
312
 
321
    mcall
313
	mcall	37,2
322
    test eax, eax	   ; check buttons state
314
	test	eax,eax	   ; check buttons state
323
    jnz  click
-
 
324
    mov  eax, 37
-
 
325
    mov  ebx, 1
315
	jnz	click
326
    mcall
316
	mcall	37,1
327
    ror  eax, 16	  ; eax = [ Y | X ] relative to window
317
	ror	eax,16	  ; eax = [ Y | X ] relative to window
328
    cmp  ax,  140	   ; pointer in window?
318
	cmp	ax,140	   ; pointer in window?
329
    ja	   noinwindow
319
	ja	noinwindow
330
;  in window 
-
 
331
 
320
; *** in window ***
332
    shr  eax, 16	  ; eax = [ 0 | Y ]
321
	shr	eax,16	  ; eax = [ 0 | Y ]
333
    xor  edx, edx
322
	xor	edx,edx
334
    mov  ebx, BTN_HEIGHT
323
	mov	ebx,BTN_HEIGHT
335
    div  ebx
324
	div	ebx
Line 338... Line 327...
338
    cmp  eax, ebx
327
	cmp	eax,ebx
339
    ja	   noinwindow
328
	ja	noinwindow
340
    cmp  [edi + cur_sel], al
329
	cmp	[edi + cur_sel],al
341
    je	   noredrawbut
330
	je	noredrawbut
342
    mov  bl, [edi + cur_sel]
331
	mov	bl,[edi + cur_sel]
343
 
-
 
344
   ;;;;;;
332
;;;;;;
345
    cmp  [edi + child], 0
333
	cmp	[edi + child],0
346
    jne  noredrawbut
334
	jne	noredrawbut
347
   ;;;;;;
335
;;;;;;
348
 
-
 
349
    mov  [edi + cur_sel], al
336
	mov	[edi + cur_sel],al
350
    mov  [edi + prev_sel], bl
337
	mov	[edi + prev_sel],bl
351
  redrawbut:
338
redrawbut:
352
    call draw_only_needed_buttons
339
	call	draw_only_needed_buttons
353
  noredrawbut:
340
noredrawbut:
354
    call backconvert
341
	call	backconvert
355
    bts  [mousemask], eax
342
	bts	[mousemask],eax
356
    jmp  still
343
	jmp	still
-
 
344
;---------------------------------------------------------------------
357
  noinwindow:
345
noinwindow:
358
    call backconvert
346
	call	backconvert
359
    btr  [mousemask], eax
347
	btr	[mousemask],eax
360
    jmp  still
348
	jmp	still
-
 
349
;---------------------------------------------------------------------
361
  click:
350
click:
362
    cmp  [mousemask], 0  ; not in a window (i.e. menu)
351
	cmp	[mousemask],0  ; not in a window (i.e. menu)
-
 
352
	jne	still
-
 
353
; checking for pressing 'MENU' on the taskbar	
-
 
354
	mov	eax,[screen_mouse_position]
-
 
355
	mov	ebx,[screen_size]
-
 
356
	sub	bx,PANEL_HEIGHT
-
 
357
	cmp	bx,ax
363
    je	   close
358
	ja	close
364
    jmp  still
359
	shr	eax,16
-
 
360
	cmp	ax,MENU_BOTTON_X_SIZE
365
 
361
	ja	close
-
 
362
	cmp	ax,MENU_BOTTON_X_POS
366
 
363
	ja	still
-
 
364
;---------------------------------------------------------------------
367
  close:
365
close:
-
 
366
	
368
        movzx   ebx, [edi+parent]       ; parent id
367
	movzx	ebx,[edi+parent]       ; parent id
369
        shl     ebx, 4
368
	shl	ebx,4
370
        add     ebx, menu_data          ; ebx = base of parent info
369
	add	ebx,menu_data          ; ebx = base of parent info
371
        call    backconvert
370
	call	backconvert
372
        cmp     [ebx + child], al       ; if i am the child of my parent...
371
	cmp	[ebx + child],al       ; if i am the child of my parent...
Line 374... Line 373...
374
        mov     [ebx + child], -1       ; ...my parent now has no children
373
	mov	[ebx + child],-1       ; ...my parent now has no children
375
@@:
374
@@:
376
        or      eax, -1                 ; close this thread
375
	or	eax,-1                 ; close this thread
377
        mov     [edi + child], al       ; my child is not mine
376
	mov	[edi + child],al       ; my child is not mine
378
        mcall
377
	mcall
379
 
-
 
380
  backconvert:		  ; convert from pointer to process id
378
backconvert:		  ; convert from pointer to process id
381
    mov  eax, edi
379
	mov	eax,edi
382
    sub  eax, menu_data
380
	sub	eax,menu_data
383
    shr  eax, 4
381
	shr	eax,4
384
    ret
382
	ret
385
 
-
 
386
 
-
 
-
 
383
;---------------------------------------------------------------------
387
;==================================
384
;==================================
388
; get_number
385
; get_number
389
;    load number from [edi] to ebx
386
;    load number from [edi] to ebx
390
;==================================
387
;==================================
391
  get_number:
388
get_number:
392
    push edi
389
	push	edi
393
 
-
 
394
    xor  eax, eax
390
	xor	eax,eax
395
    xor  ebx, ebx
391
	xor	ebx,ebx
396
 
-
 
397
   .get_next_char:
392
.get_next_char:
398
    mov  al, [edi]
393
	mov	al,[edi]
399
    inc  edi
394
	inc	edi
400
    cmp  al, '0'
395
	cmp	al, '0'
401
    jb	   .finish
396
	jb	.finish
Line 403... Line 398...
403
    ja	   .finish
398
	ja	.finish
404
    sub  al, '0'
399
	sub	al, '0'
405
    imul ebx, 10
400
	imul	ebx,10
406
    add  ebx, eax
401
	add	ebx,eax
407
    jmp  .get_next_char
402
	jmp	.get_next_char
408
 
-
 
-
 
403
;-------------------------------------
409
   .finish:
404
.finish:
410
    pop  edi
405
	pop	edi
411
    ret
406
	ret
-
 
407
;---------------------------------------------------------------------
-
 
408
get_process_ID:
-
 
409
	mcall	9,procinfo,-1
-
 
410
	mov	edx,eax
-
 
411
	mov	ecx,[ebx+30]	; PID
-
 
412
	ret
-
 
413
;---------------------------------------------------------------------
-
 
414
program_exist:
-
 
415
	call	get_process_ID
-
 
416
	mov	[main_process_ID],ecx
-
 
417
	mcall	18,21
-
 
418
	mov	[active_process],eax	; WINDOW SLOT
-
 
419
	mov	ecx,edx
-
 
420
	xor	edx,edx
-
 
421
;-----------------------------------------
-
 
422
.loop:
-
 
423
	push	ecx
-
 
424
	mcall	9,procinfo
-
 
425
	mov	eax,[menu_mame]
-
 
426
	cmp	[ebx+10],eax
-
 
427
	jne	@f
-
 
428
	mov	ax,[menu_mame+4]
-
 
429
	cmp	[ebx+14],ax
-
 
430
	jne	@f
-
 
431
	cmp	ecx,[active_process]
-
 
432
	je	@f
-
 
433
; dph ecx
-
 
434
	mcall	18,2
-
 
435
	mov	edx,1
412
 
436
@@:
-
 
437
	pop	ecx
-
 
438
	loop	.loop
-
 
439
;-----------------------------------------	
-
 
440
	test	edx,edx
-
 
441
	jz	@f
-
 
442
	mcall	-1
413
 
443
@@:
-
 
444
	ret
-
 
445
;---------------------------------------------------------------------
414
;   *********************************************
446
;   *********************************************
415
;   *******  WINDOW DEFINITIONS AND DRAW ********
447
;   *******  WINDOW DEFINITIONS AND DRAW ********
416
;   *********************************************
448
;   *********************************************
417
 
-
 
418
 
-
 
419
draw_window:
449
draw_window:
420
 
-
 
421
    mov  eax, 12	   ; function 12:tell os about windowdraw
-
 
422
    mov  ebx, 1 	   ; 1, start of draw
450
	mcall	12,1	; 1,start of draw
423
    mcall
-
 
424
 
-
 
425
  movzx  ebx, [edi + rows]
451
	movzx	ebx,[edi + rows]
426
   imul  eax, ebx, BTN_HEIGHT	    ; eax = height of window
452
	imul	eax,ebx,BTN_HEIGHT	    ; eax = height of window
427
  movzx  ecx, [edi + y_end]
453
	movzx	ecx,[edi + y_end]
428
    sub  ecx, eax	    ; ecx = Y_START
454
	sub	ecx,eax	    ; ecx = Y_START
429
    shl  ecx, 16
455
	shl	ecx,16
430
    add  ecx, eax	    ; ecx = [ Y_START | Y_SIZE ]
456
	add	ecx,eax	    ; ecx = [ Y_START | Y_SIZE ]
431
    dec  ecx
457
	dec	ecx
432
  movzx  ebx, [edi + x_start]
458
	movzx	ebx,[edi + x_start]
433
    shl  ebx, 16
459
	shl	ebx,16
434
    mov  bx,  140	    ; ebx = [ X_START | X_SIZE ]
460
	mov	bx,140	    ; ebx = [ X_START | X_SIZE ]
435
    xor  eax, eax	    ; function 0 : define and draw window
-
 
436
    mov  edx, 0x01000000       ; color of work area RRGGBB,8->color gl
461
	mov	edx,0x01000000       ; color of work area RRGGBB,8->color gl
437
    mov  esi, edx	    ; unmovable window
462
	mov	esi,edx	    ; unmovable window
-
 
463
	xor	eax,eax	    ; function 0 : define and draw window
438
    mcall
464
	mcall
Line 439... Line 465...
439
 
465
	
440
    call draw_all_buttons
-
 
441
 
-
 
442
    mov  eax,12
-
 
443
    mov  ebx,2
466
	call	draw_all_buttons
444
    mcall
-
 
445
 
467
	mcall	12,2
446
    ret
-
 
447
 
-
 
-
 
468
	ret
448
 
469
;---------------------------------------------------------------------
449
 draw_all_buttons:
470
draw_all_buttons:
450
    xor  edx, edx
471
	xor	edx,edx
451
  .new_button:
472
.new_button:
452
    call draw_one_button
473
	call	draw_one_button
453
    inc  edx
474
	inc	edx
454
    cmp  dl, [edi + rows]
475
	cmp	dl,[edi + rows]
455
    jb	   .new_button
-
 
456
 
476
	jb	.new_button
457
    ret
-
 
458
 
-
 
-
 
477
	ret
459
 
478
;---------------------------------------------------------------------
460
 draw_only_needed_buttons:
479
draw_only_needed_buttons:
461
    xor  edx, edx
480
	xor	edx,edx
462
    mov  dl, [edi + cur_sel]
481
	mov	dl,[edi + cur_sel]
463
    dec  dl
482
	dec	dl
464
    call draw_one_button
483
	call	draw_one_button
465
    mov  dl, [edi + prev_sel]
484
	mov	dl,[edi + prev_sel]
466
    dec  dl
485
	dec	dl
467
    call draw_one_button
486
	call	draw_one_button
468
    ret
-
 
469
 
-
 
-
 
487
	ret
470
 
488
;---------------------------------------------------------------------
471
 draw_one_button:
489
draw_one_button:
472
 ; receives number of button in dl
490
; receives number of button in dl
473
    push edx;ad
-
 
474
 
491
	push	edx
475
    mov  eax, 8
492
	mov	eax,8
476
    mov  ebx, 140
493
	mov	ebx,140
477
  movzx  ecx, dl
494
	movzx	ecx,dl
478
    imul ecx, BTN_HEIGHT
495
	imul	ecx,BTN_HEIGHT
Line 489... Line 506...
489
    jne  .nohighlight
506
	jne	.nohighlight
490
    add  esi, 0x1a1a1a
507
	add	esi,0x1a1a1a
491
  .nohighlight:
508
.nohighlight:
492
    or	   edx, 0x20000000
509
	or	edx,0x20000000
493
                                ; dunkaist[
510
				; dunkaist[
494
    add  edx, 0xd1ff00          ; This makes first menu buttons differ from system close button with 0x000001 id
511
	add	edx,0xd1ff00	; This makes first menu buttons differ
-
 
512
				; from system close button with 0x000001 id
495
                                ; dunkaist]
513
				; dunkaist]
496
    mcall
514
	mcall
497
    movzx edx, dl
515
	movzx	edx,dl
498
 
-
 
499
    dec  dl
516
	dec	dl
500
    imul ebx, edx, BTN_HEIGHT
517
	imul	ebx,edx,BTN_HEIGHT
501
    add  ebx, (4 shl 16) + TXT_Y
518
	add	ebx,(4 shl 16) + TXT_Y
502
 
-
 
503
  movzx  ecx, dl
519
	movzx	ecx,dl
504
    inc  ecx
520
	inc	ecx
505
    mov  edx, [edi + pointer]
521
	mov	edx,[edi + pointer]
506
  .findline:
522
.findline:
507
    cmp  byte [edx], 13
523
	cmp	byte [edx],13
508
    je	   .linefound
524
	je	.linefound
509
    inc  edx
525
	inc	edx
510
    jmp  .findline
526
	jmp	.findline
-
 
527
;---------------------------------------------------------------------
511
  .linefound:
528
.linefound:
512
    inc  edx
529
	inc	edx
513
    cmp  byte [edx], 10
530
	cmp	byte [edx],10
514
    jne  .findline
531
	jne	.findline
515
    dec  ecx
532
	dec	ecx
516
    jnz  .findline
533
	jnz	.findline
Line 517... Line 534...
517
 
534
	
518
    mov  ecx, [sc.work_text]
-
 
519
    mov  eax, 4
-
 
520
    mov  esi, 21
-
 
521
    mcall
-
 
522
 
535
	mcall	4,,[sc.work_text],,21
523
    pop  edx;ad
536
	pop	edx
524
    ret
-
 
525
 
-
 
-
 
537
	ret
526
 
538
;---------------------------------------------------------------------
527
 searchstartstring:
539
searchstartstring:
528
    mov  ecx, 40
540
	mov	ecx,40
529
    mov  al, 13
541
	mov	al,13
530
    cld
542
	cld
531
  repne  scasb
543
	repne	scasb
532
    cmp  byte [edi], 10
544
	cmp	byte [edi],10
533
    jne  searchstartstring
545
	jne	searchstartstring
534
    ret
-
 
535
 
-
 
-
 
546
	ret
536
 
547
;---------------------------------------------------------------------
-
 
548
;*** DATA AREA ****************************************************************
-
 
549
menu_mame:
Line 537... Line 550...
537
;*** DATA AREA ****************************************************************
550
	db '@MENU',0
538
 
551
 
Line 539... Line 552...
539
thread_stack   dd   0xE000
552
thread_stack   dd 0xE000
Line 554... Line 567...
554
 .params	 dd   0x0	 ; nop
567
 .params	dd 0x0	 ; nop
555
 .rezerved	 dd   0x0	 ; nop
568
 .rezerved	dd 0x0	 ; nop
556
 .rezerved_1	 dd   0x0	 ; nop
569
 .rezerved_1	dd 0x0	 ; nop
557
 .name:
570
 .name:
558
   times 50 db ' '
571
   times 50 db ' '
559
 
-
 
-
 
572
;---------------------------------------------------------------------
560
I_END:
573
I_END:
561
 
-
 
-
 
574
;---------------------------------------------------------------------
562
close_now      dd ?   ; close all processes immediately
575
close_now	dd ?   ; close all processes immediately
563
end_pointer    dd ?
576
end_pointer	dd ?
564
buffer		 dd ?
577
buffer		dd ?
565
mousemask      dd ?   ; mask for mouse pointer location
578
mousemask	dd ?   ; mask for mouse pointer location
Line -... Line 579...
-
 
579
 
-
 
580
active_process	dd ?
-
 
581
main_process_ID	dd ?
-
 
582
 
-
 
583
screen_mouse_position:
-
 
584
.y	dw ?
-
 
585
.x	dw ?
-
 
586
 
-
 
587
screen_size:
-
 
588
.y	dw ?
-
 
589
.x	dw ?
-
 
590
 
566
 
591
 
Line 567... Line 592...
567
sc system_colors
592
sc system_colors
568
 
593
 
Line 579... Line 604...
579
  cur_sel      db ?   ; +11   current selection
604
  cur_sel	db ?   ; +11   current selection
580
  prev_sel     db ?   ; +12   previous selection
605
  prev_sel	db ?   ; +12   previous selection
581
  rb	       16-$+1 ; [16 bytes per element]
606
  rb		16-$+1 ; [16 bytes per element]
582
end virtual
607
end virtual
Line -... Line 608...
-
 
608
 
-
 
609
last_key	db ?
-
 
610
;---------------------------------------------------------------------
-
 
611
align 4
-
 
612
procinfo:
-
 
613
	rb 1024
583
 
614
;---------------------------------------------------------------------
-
 
615
mem_end:
584
mem_end:
616
;---------------------------------------------------------------------