Subversion Repositories Kolibri OS

Rev

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

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