Subversion Repositories Kolibri OS

Rev

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

Rev 529 Rev 728
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
 
194
  button1:
194
  button1:
195
    mov  esi, edi
195
    mov  esi, edi
196
    push edi
196
    push edi
197
    mov  edi, [edi + pointer]
197
    mov  edi, [edi + pointer]
198
 
198
 
199
; print "hello"
199
; print "hello"
200
    mov  al, [esi + cur_sel]
200
    mov  al, [esi + cur_sel]
201
    mov  [esi + prev_sel], al
201
    mov  [esi + prev_sel], al
202
    mov  [esi + cur_sel], ah
202
    mov  [esi + cur_sel], ah
203
    pushad
203
    pushad
204
    mov edi, esi
204
    mov edi, esi
205
;    dph eax
205
;    dph eax
206
    call draw_only_needed_buttons
206
    call draw_only_needed_buttons
207
    popad
207
    popad
208
 
208
 
209
    ; look for the next line  times;  = button_id
209
    ; look for the next line  times;  = button_id
210
    push eax
210
    push eax
211
  .next_string:
211
  .next_string:
212
    call searchstartstring
212
    call searchstartstring
213
    dec  ah
213
    dec  ah
214
    jnz  .next_string
214
    jnz  .next_string
215
    pop  eax
215
    pop  eax
216
 
216
 
217
    mov  ecx, 40
217
    mov  ecx, 40
218
    mov  al, '/'
218
    mov  al, '/'
219
    cld
219
    cld
220
  repne  scasb
220
  repne  scasb
221
    test ecx, ecx	  ; if '/' not found
221
    test ecx, ecx	  ; if '/' not found
222
    je	   searchexit
222
    je	   searchexit
223
 
223
 
224
    cmp  [edi], byte '@'     ; check for submenu
224
    cmp  [edi], byte '@'     ; check for submenu
225
    je	   runthread
225
    je	   runthread
226
 
226
 
227
    dec  edi
227
    dec  edi
228
    push edi		 ; pointer to start of filename
228
    push edi		 ; pointer to start of filename
229
    call searchstartstring   ; search for next string
229
    call searchstartstring   ; search for next string
230
    sub  edi, 2 	 ; to last byte of string
230
    sub  edi, 2 	 ; to last byte of string
231
 
231
 
232
    mov  ecx, edi
232
    mov  ecx, edi
233
    pop  esi
233
    pop  esi
234
    sub  ecx, esi
234
    sub  ecx, esi
235
    inc  ecx		 ; length of filename
235
    inc  ecx		 ; length of filename
236
    mov  edi, fileinfo_start.name
236
    mov  edi, fileinfo_start.name
237
    rep  movsb		   ; copy string
237
    rep  movsb		   ; copy string
238
    mov  byte [edi], 0	       ; store terminator
238
    mov  byte [edi], 0	       ; store terminator
239
    mov  eax, 70	 ; start program
239
    mov  eax, 70	 ; start program
240
    mov  ebx, fileinfo_start
240
    mov  ebx, fileinfo_start
241
    mcall
241
    mcall
242
;    mcall 5,100
242
;    mcall 5,100
243
    or	   [close_now], 1      ; set close flag
243
    or	   [close_now], 1      ; set close flag
244
    pop  edi
244
    pop  edi
245
    mov  [mousemask], 0
245
    mov  [mousemask], 0
246
    jmp  close
246
    jmp  close
247
 
247
 
248
  searchexit:
248
  searchexit:
249
    pop  edi
249
    pop  edi
250
    jmp  still
250
    jmp  still
251
 
251
 
252
 
252
 
253
  runthread:
253
  runthread:
254
    inc  edi
254
    inc  edi
255
 
255
 
256
    push eax
256
    push eax
257
    call get_number	     ; get number of this process
257
    call get_number	     ; get number of this process
258
    pop  eax
258
    pop  eax
259
 
259
 
260
    test ebx, ebx	   ; returned zero - main menu or not number
260
    test ebx, ebx	   ; returned zero - main menu or not number
261
    jz	   searchexit
261
    jz	   searchexit
262
 
262
 
263
    mov  al, bl
263
    mov  al, bl
264
 
264
 
265
    mov  ebx, [processes]
265
    mov  ebx, [processes]
266
    dec  bl
266
    dec  bl
267
    cmp  al, bl
267
    cmp  al, bl
268
    ja	   searchexit	       ; such process doesnt exist
268
    ja	   searchexit	       ; such process doesnt exist
269
    cmp  al, [esi + child]
269
    cmp  al, [esi + child]
270
    je	   searchexit	       ; such process already exists
270
    je	   searchexit	       ; such process already exists
271
 
271
 
272
    mov  [esi + child], al    ; this is my child
272
    mov  [esi + child], al    ; this is my child
273
    mov  cx, [esi + x_start]
273
    mov  cx, [esi + x_start]
274
    add  cx, 141	  ; new x_start in cx
274
    add  cx, 141	  ; new x_start in cx
275
  movzx  edx, al
275
  movzx  edx, al
276
    shl  edx, 4
276
    shl  edx, 4
277
    add  edx, menu_data       ; edx points to child's base address
277
    add  edx, menu_data       ; edx points to child's base address
278
    mov  [edx + x_start], cx  ; xstart for new thread
278
    mov  [edx + x_start], cx  ; xstart for new thread
279
    mov  cx,  [esi + y_end]   ; y_end in cx
279
    mov  cx,  [esi + y_end]   ; y_end in cx
280
    mov  bl,  [esi + rows]    ; number of buttons in bl
280
    mov  bl,  [esi + rows]    ; number of buttons in bl
281
    sub  bl,  ah	  ; number of btn from bottom
281
    sub  bl,  ah	  ; number of btn from bottom
282
  movzx  eax, al
282
  movzx  eax, al
283
    mov  [buffer], eax		; thread id in buffer
283
    mov  [buffer], eax		; thread id in buffer
284
  movzx  ebx, bl
284
  movzx  ebx, bl
285
    push edx
285
    push edx
286
    mov  eax, BTN_HEIGHT
286
    mov  eax, BTN_HEIGHT
287
    mul  ebx
287
    mul  ebx
288
    sub  cx,  ax	  ; new y_end for new thread
288
    sub  cx,  ax	  ; new y_end for new thread
289
    pop  edx
289
    pop  edx
290
    mov  [edx + y_end], cx    ; store y_end
290
    mov  [edx + y_end], cx    ; store y_end
291
    mov  edi, esi
291
    mov  edi, esi
292
    call backconvert	      ; get number of this process (al)
292
    call backconvert	      ; get number of this process (al)
293
    mov  [edx + parent], al   ; store number of parent process
293
    mov  [edx + parent], al   ; store number of parent process
294
    mov  al, [edx + rows]
294
    mov  al, [edx + rows]
295
    mov  [edx + cur_sel], al  ; clear current selected element
295
    mov  [edx + cur_sel], al  ; clear current selected element
296
    mov  [edx + prev_sel], al ; clear previous selected element
296
    mov  [edx + prev_sel], al ; clear previous selected element
297
    mov  [edx + child], 0
297
    mov  [edx + child], 0
298
 
298
 
299
    cmp  [thread_stack], 0x1e000
299
    cmp  [thread_stack], 0x1e000
300
    jne  thread_stack_not_full
300
    jne  thread_stack_not_full
301
    mov  [thread_stack], 0xE000
301
    mov  [thread_stack], 0xE000
302
 
302
 
303
thread_stack_not_full:
303
thread_stack_not_full:
304
    add  [thread_stack], 0x2000 ; start new thread
304
    add  [thread_stack], 0x2000 ; start new thread
305
    mov  eax, 51
305
    mov  eax, 51
306
    mov  ebx, 1
306
    mov  ebx, 1
307
    mov  ecx, thread
307
    mov  ecx, thread
308
    mov  edx, [thread_stack]
308
    mov  edx, [thread_stack]
309
    mcall
309
    mcall
310
 
310
 
311
    jmp  searchexit
311
    jmp  searchexit
312
 
312
 
313
 
313
 
314
 mouse: 	      ; MOUSE EVENT HANDLER
314
 mouse: 	      ; MOUSE EVENT HANDLER
315
    mov  eax, 37
315
    mov  eax, 37
316
    mov  ebx, 2
316
    mov  ebx, 2
317
    mcall
317
    mcall
318
    test eax, eax	   ; check buttons state
318
    test eax, eax	   ; check buttons state
319
    jnz  click
319
    jnz  click
320
    mov  eax, 37
320
    mov  eax, 37
321
    mov  ebx, 1
321
    mov  ebx, 1
322
    mcall
322
    mcall
323
    ror  eax, 16	  ; eax = [ Y | X ] relative to window
323
    ror  eax, 16	  ; eax = [ Y | X ] relative to window
324
    cmp  ax,  140	   ; pointer in window?
324
    cmp  ax,  140	   ; pointer in window?
325
    ja	   noinwindow
325
    ja	   noinwindow
326
;  in window 
326
;  in window 
327
 
327
 
328
    shr  eax, 16	  ; eax = [ 0 | Y ]
328
    shr  eax, 16	  ; eax = [ 0 | Y ]
329
    xor  edx, edx
329
    xor  edx, edx
330
    mov  ebx, BTN_HEIGHT
330
    mov  ebx, BTN_HEIGHT
331
    div  ebx
331
    div  ebx
332
    inc  eax		  ; number of "button" in eax
332
    inc  eax		  ; number of "button" in eax
333
  movzx  ebx, [edi + rows]    ; total strings in ebx
333
  movzx  ebx, [edi + rows]    ; total strings in ebx
334
    cmp  eax, ebx
334
    cmp  eax, ebx
335
    ja	   noinwindow
335
    ja	   noinwindow
336
    cmp  [edi + cur_sel], al
336
    cmp  [edi + cur_sel], al
337
    je	   noredrawbut
337
    je	   noredrawbut
338
    mov  bl, [edi + cur_sel]
338
    mov  bl, [edi + cur_sel]
339
 
339
 
340
   ;;;;;;
340
   ;;;;;;
341
    cmp  [edi + child], 0
341
    cmp  [edi + child], 0
342
    jne  noredrawbut
342
    jne  noredrawbut
343
   ;;;;;;
343
   ;;;;;;
344
 
344
 
345
    mov  [edi + cur_sel], al
345
    mov  [edi + cur_sel], al
346
    mov  [edi + prev_sel], bl
346
    mov  [edi + prev_sel], bl
347
  redrawbut:
347
  redrawbut:
348
    call draw_only_needed_buttons
348
    call draw_only_needed_buttons
349
  noredrawbut:
349
  noredrawbut:
350
    call backconvert
350
    call backconvert
351
    bts  [mousemask], eax
351
    bts  [mousemask], eax
352
    jmp  still
352
    jmp  still
353
  noinwindow:
353
  noinwindow:
354
    call backconvert
354
    call backconvert
355
    btr  [mousemask], eax
355
    btr  [mousemask], eax
356
    jmp  still
356
    jmp  still
357
  click:
357
  click:
358
    cmp  [mousemask], 0  ; not in a window (i.e. menu)
358
    cmp  [mousemask], 0  ; not in a window (i.e. menu)
359
    je	   close
359
    je	   close
360
    jmp  still
360
    jmp  still
361
 
361
 
362
 
362
 
363
  close:
363
  close:
-
 
364
        movzx   ebx, [edi+parent]       ; parent id
-
 
365
        shl     ebx, 4
-
 
366
        add     ebx, menu_data          ; ebx = base of parent info
-
 
367
        call    backconvert
-
 
368
        cmp     [ebx + child], al       ; if i am the child of my parent...
-
 
369
        jnz     @f
-
 
370
        mov     [ebx + child], -1       ; ...my parent now has no children
-
 
371
@@:
364
    or	   eax, -1	  ; close this thread
372
        or      eax, -1                 ; close this thread
365
    mov  [edi + child], al    ; my child is not mine
373
        mov     [edi + child], al       ; my child is not mine
366
    mcall
374
        mcall
367
 
-
 
368
 
375
 
369
  backconvert:		  ; convert from pointer to process id
376
  backconvert:		  ; convert from pointer to process id
370
    mov  eax, edi
377
    mov  eax, edi
371
    sub  eax, menu_data
378
    sub  eax, menu_data
372
    shr  eax, 4
379
    shr  eax, 4
373
    ret
380
    ret
374
 
381
 
375
 
382
 
376
;==================================
383
;==================================
377
; get_number
384
; get_number
378
;    load number from [edi] to ebx
385
;    load number from [edi] to ebx
379
;==================================
386
;==================================
380
  get_number:
387
  get_number:
381
    push edi
388
    push edi
382
 
389
 
383
    xor  eax, eax
390
    xor  eax, eax
384
    xor  ebx, ebx
391
    xor  ebx, ebx
385
 
392
 
386
   .get_next_char:
393
   .get_next_char:
387
    mov  al, [edi]
394
    mov  al, [edi]
388
    inc  edi
395
    inc  edi
389
    cmp  al, '0'
396
    cmp  al, '0'
390
    jb	   .finish
397
    jb	   .finish
391
    cmp  al, '9'
398
    cmp  al, '9'
392
    ja	   .finish
399
    ja	   .finish
393
    sub  al, '0'
400
    sub  al, '0'
394
    imul ebx, 10
401
    imul ebx, 10
395
    add  ebx, eax
402
    add  ebx, eax
396
    jmp  .get_next_char
403
    jmp  .get_next_char
397
 
404
 
398
   .finish:
405
   .finish:
399
    pop  edi
406
    pop  edi
400
    ret
407
    ret
401
 
408
 
402
 
409
 
403
;   *********************************************
410
;   *********************************************
404
;   *******  WINDOW DEFINITIONS AND DRAW ********
411
;   *******  WINDOW DEFINITIONS AND DRAW ********
405
;   *********************************************
412
;   *********************************************
406
 
413
 
407
 
414
 
408
draw_window:
415
draw_window:
409
 
416
 
410
    mov  eax, 12	   ; function 12:tell os about windowdraw
417
    mov  eax, 12	   ; function 12:tell os about windowdraw
411
    mov  ebx, 1 	   ; 1, start of draw
418
    mov  ebx, 1 	   ; 1, start of draw
412
    mcall
419
    mcall
413
 
420
 
414
  movzx  ebx, [edi + rows]
421
  movzx  ebx, [edi + rows]
415
   imul  eax, ebx, BTN_HEIGHT	    ; eax = height of window
422
   imul  eax, ebx, BTN_HEIGHT	    ; eax = height of window
416
  movzx  ecx, [edi + y_end]
423
  movzx  ecx, [edi + y_end]
417
    sub  ecx, eax	    ; ecx = Y_START
424
    sub  ecx, eax	    ; ecx = Y_START
418
    shl  ecx, 16
425
    shl  ecx, 16
419
    add  ecx, eax	    ; ecx = [ Y_START | Y_SIZE ]
426
    add  ecx, eax	    ; ecx = [ Y_START | Y_SIZE ]
420
    dec  ecx
427
    dec  ecx
421
  movzx  ebx, [edi + x_start]
428
  movzx  ebx, [edi + x_start]
422
    shl  ebx, 16
429
    shl  ebx, 16
423
    mov  bx,  140	    ; ebx = [ X_START | X_SIZE ]
430
    mov  bx,  140	    ; ebx = [ X_START | X_SIZE ]
424
    xor  eax, eax	    ; function 0 : define and draw window
431
    xor  eax, eax	    ; function 0 : define and draw window
425
    mov  edx, 0x01000000       ; color of work area RRGGBB,8->color gl
432
    mov  edx, 0x01000000       ; color of work area RRGGBB,8->color gl
426
    mov  esi, edx	    ; unmovable window
433
    mov  esi, edx	    ; unmovable window
427
    mcall
434
    mcall
428
 
435
 
429
    call draw_all_buttons
436
    call draw_all_buttons
430
 
437
 
431
    mov  eax,12
438
    mov  eax,12
432
    mov  ebx,2
439
    mov  ebx,2
433
    mcall
440
    mcall
434
 
441
 
435
    ret
442
    ret
436
 
443
 
437
 
444
 
438
 draw_all_buttons:
445
 draw_all_buttons:
439
    xor  edx, edx
446
    xor  edx, edx
440
  .new_button:
447
  .new_button:
441
    call draw_one_button
448
    call draw_one_button
442
    inc  edx
449
    inc  edx
443
    cmp  dl, [edi + rows]
450
    cmp  dl, [edi + rows]
444
    jb	   .new_button
451
    jb	   .new_button
445
 
452
 
446
    ret
453
    ret
447
 
454
 
448
 
455
 
449
 draw_only_needed_buttons:
456
 draw_only_needed_buttons:
450
    xor  edx, edx
457
    xor  edx, edx
451
    mov  dl, [edi + cur_sel]
458
    mov  dl, [edi + cur_sel]
452
    dec  dl
459
    dec  dl
453
    call draw_one_button
460
    call draw_one_button
454
    mov  dl, [edi + prev_sel]
461
    mov  dl, [edi + prev_sel]
455
    dec  dl
462
    dec  dl
456
    call draw_one_button
463
    call draw_one_button
457
    ret
464
    ret
458
 
465
 
459
 
466
 
460
 draw_one_button:
467
 draw_one_button:
461
 ; receives number of button in dl
468
 ; receives number of button in dl
462
    push edx;ad
469
    push edx;ad
463
 
470
 
464
    mov  eax, 8
471
    mov  eax, 8
465
    mov  ebx, 140
472
    mov  ebx, 140
466
  movzx  ecx, dl
473
  movzx  ecx, dl
467
    imul ecx, BTN_HEIGHT
474
    imul ecx, BTN_HEIGHT
468
    shl  ecx, 16
475
    shl  ecx, 16
469
    add  ecx, BTN_HEIGHT-1
476
    add  ecx, BTN_HEIGHT-1
470
;   edx = button identifier
477
;   edx = button identifier
471
    mov  esi, [sc.work]
478
    mov  esi, [sc.work]
472
    cmp  esi, 0xdfdfdf
479
    cmp  esi, 0xdfdfdf
473
    jb   nocorrect
480
    jb   nocorrect
474
    sub  esi, 0x1b1b1b
481
    sub  esi, 0x1b1b1b
475
  nocorrect: 
482
  nocorrect: 
476
    inc  dl
483
    inc  dl
477
    cmp  [edi + cur_sel], dl
484
    cmp  [edi + cur_sel], dl
478
    jne  .nohighlight
485
    jne  .nohighlight
479
    add  esi, 0x1a1a1a
486
    add  esi, 0x1a1a1a
480
  .nohighlight:
487
  .nohighlight:
481
    or	   edx, 0x20000000
488
    or	   edx, 0x20000000
482
    mcall
489
    mcall
483
    movzx edx, dl
490
    movzx edx, dl
484
 
491
 
485
    dec  dl
492
    dec  dl
486
    imul ebx, edx, BTN_HEIGHT
493
    imul ebx, edx, BTN_HEIGHT
487
    add  ebx, (4 shl 16) + TXT_Y
494
    add  ebx, (4 shl 16) + TXT_Y
488
 
495
 
489
  movzx  ecx, dl
496
  movzx  ecx, dl
490
    inc  ecx
497
    inc  ecx
491
    mov  edx, [edi + pointer]
498
    mov  edx, [edi + pointer]
492
  .findline:
499
  .findline:
493
    cmp  byte [edx], 13
500
    cmp  byte [edx], 13
494
    je	   .linefound
501
    je	   .linefound
495
    inc  edx
502
    inc  edx
496
    jmp  .findline
503
    jmp  .findline
497
  .linefound:
504
  .linefound:
498
    inc  edx
505
    inc  edx
499
    cmp  byte [edx], 10
506
    cmp  byte [edx], 10
500
    jne  .findline
507
    jne  .findline
501
    dec  ecx
508
    dec  ecx
502
    jnz  .findline
509
    jnz  .findline
503
 
510
 
504
    mov  ecx, [sc.work_text]
511
    mov  ecx, [sc.work_text]
505
    mov  eax, 4
512
    mov  eax, 4
506
    mov  esi, 21
513
    mov  esi, 21
507
    mcall
514
    mcall
508
 
515
 
509
    pop  edx;ad
516
    pop  edx;ad
510
    ret
517
    ret
511
 
518
 
512
 
519
 
513
 searchstartstring:
520
 searchstartstring:
514
    mov  ecx, 40
521
    mov  ecx, 40
515
    mov  al, 13
522
    mov  al, 13
516
    cld
523
    cld
517
  repne  scasb
524
  repne  scasb
518
    cmp  byte [edi], 10
525
    cmp  byte [edi], 10
519
    jne  searchstartstring
526
    jne  searchstartstring
520
    ret
527
    ret
521
 
528
 
522
 
529
 
523
;*** DATA AREA ****************************************************************
530
;*** DATA AREA ****************************************************************
524
 
531
 
525
thread_stack   dd   0xE000
532
thread_stack   dd   0xE000
526
processes      dd   0
533
processes      dd   0
527
 
534
 
528
fileinfo:
535
fileinfo:
529
 .subfunction	 dd   0 	      ; 0=READ
536
 .subfunction	 dd   0 	      ; 0=READ
530
 .start 	 dd   0 	      ; start byte
537
 .start 	 dd   0 	      ; start byte
531
 .size_high	 dd   0 	      ; rezerved
538
 .size_high	 dd   0 	      ; rezerved
532
 .size		 dd   0x10000-mem_end ; blocks to read
539
 .size		 dd   0x10000-mem_end ; blocks to read
533
 .return	 dd   mem_end	      ; return data pointer
540
 .return	 dd   mem_end	      ; return data pointer
534
 .name:
541
 .name:
535
     db   '/sys/MENU.DAT',0   ; ASCIIZ dir & filename
542
     db   '/sys/MENU.DAT',0   ; ASCIIZ dir & filename
536
 
543
 
537
fileinfo_start:
544
fileinfo_start:
538
 .subfunction	 dd   7 	 ; 7=START APPLICATION
545
 .subfunction	 dd   7 	 ; 7=START APPLICATION
539
 .flags 	 dd   0 	 ; flags
546
 .flags 	 dd   0 	 ; flags
540
 .params	 dd   0x0	 ; nop
547
 .params	 dd   0x0	 ; nop
541
 .rezerved	 dd   0x0	 ; nop
548
 .rezerved	 dd   0x0	 ; nop
542
 .rezerved_1	 dd   0x0	 ; nop
549
 .rezerved_1	 dd   0x0	 ; nop
543
 .name:
550
 .name:
544
   times 50 db ' '
551
   times 50 db ' '
545
 
552
 
546
I_END:
553
I_END:
547
 
554
 
548
close_now      dd ?   ; close all processes immediately
555
close_now      dd ?   ; close all processes immediately
549
end_pointer    dd ?
556
end_pointer    dd ?
550
buffer		 dd ?
557
buffer		 dd ?
551
mousemask      dd ?   ; mask for mouse pointer location
558
mousemask      dd ?   ; mask for mouse pointer location
552
 
559
 
553
sc system_colors
560
sc system_colors
554
 
561
 
555
menu_data:
562
menu_data:
556
  rb 0x4000  ;x10000
563
  rb 0x4000  ;x10000
557
 
564
 
558
virtual at 0	      ; PROCESSES TABLE (located at menu_data)
565
virtual at 0	      ; PROCESSES TABLE (located at menu_data)
559
  pointer      dd ?   ; +0    pointer in file
566
  pointer      dd ?   ; +0    pointer in file
560
  rows		 db ?	; +4    numer of strings
567
  rows		 db ?	; +4    numer of strings
561
  x_start      dw ?   ; +5    x start
568
  x_start      dw ?   ; +5    x start
562
  y_end        dw ?   ; +7    y end
569
  y_end        dw ?   ; +7    y end
563
  child        db ?   ; +9    id of child menu
570
  child        db ?   ; +9    id of child menu
564
  parent       db ?   ; +10   id of parent menu
571
  parent       db ?   ; +10   id of parent menu
565
  cur_sel      db ?   ; +11   current selection
572
  cur_sel      db ?   ; +11   current selection
566
  prev_sel     db ?   ; +12   previous selection
573
  prev_sel     db ?   ; +12   previous selection
567
  rb	       16-$+1 ; [16 bytes per element]
574
  rb	       16-$+1 ; [16 bytes per element]
568
end virtual
575
end virtual
569
 
576
 
570
mem_end:
577
mem_end: