Subversion Repositories Kolibri OS

Rev

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

Rev 318 Rev 485
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
     int  0x40
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
     int  0x40
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
     int  0x40
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
     int  0x40
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
    int  0x40
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
    int  0x40
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
    int  0x40
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
    int  0x40
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
    int  0x40
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
    int  0x40
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
    int  0x40
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
    or	   eax, -1	  ; close this thread
364
    or	   eax, -1	  ; close this thread
365
    mov  [edi + child], al    ; my child is not mine
365
    mov  [edi + child], al    ; my child is not mine
366
    int  0x40
366
    mcall
367
 
367
 
368
 
368
 
369
  backconvert:		  ; convert from pointer to process id
369
  backconvert:		  ; convert from pointer to process id
370
    mov  eax, edi
370
    mov  eax, edi
371
    sub  eax, menu_data
371
    sub  eax, menu_data
372
    shr  eax, 4
372
    shr  eax, 4
373
    ret
373
    ret
374
 
374
 
375
 
375
 
376
;==================================
376
;==================================
377
; get_number
377
; get_number
378
;    load number from [edi] to ebx
378
;    load number from [edi] to ebx
379
;==================================
379
;==================================
380
  get_number:
380
  get_number:
381
    push edi
381
    push edi
382
 
382
 
383
    xor  eax, eax
383
    xor  eax, eax
384
    xor  ebx, ebx
384
    xor  ebx, ebx
385
 
385
 
386
   .get_next_char:
386
   .get_next_char:
387
    mov  al, [edi]
387
    mov  al, [edi]
388
    inc  edi
388
    inc  edi
389
    cmp  al, '0'
389
    cmp  al, '0'
390
    jb	   .finish
390
    jb	   .finish
391
    cmp  al, '9'
391
    cmp  al, '9'
392
    ja	   .finish
392
    ja	   .finish
393
    sub  al, '0'
393
    sub  al, '0'
394
    imul ebx, 10
394
    imul ebx, 10
395
    add  ebx, eax
395
    add  ebx, eax
396
    jmp  .get_next_char
396
    jmp  .get_next_char
397
 
397
 
398
   .finish:
398
   .finish:
399
    pop  edi
399
    pop  edi
400
    ret
400
    ret
401
 
401
 
402
 
402
 
403
;   *********************************************
403
;   *********************************************
404
;   *******  WINDOW DEFINITIONS AND DRAW ********
404
;   *******  WINDOW DEFINITIONS AND DRAW ********
405
;   *********************************************
405
;   *********************************************
406
 
406
 
407
 
407
 
408
draw_window:
408
draw_window:
409
 
409
 
410
    mov  eax, 12	   ; function 12:tell os about windowdraw
410
    mov  eax, 12	   ; function 12:tell os about windowdraw
411
    mov  ebx, 1 	   ; 1, start of draw
411
    mov  ebx, 1 	   ; 1, start of draw
412
    int  0x40
412
    mcall
413
 
413
 
414
  movzx  ebx, [edi + rows]
414
  movzx  ebx, [edi + rows]
415
   imul  eax, ebx, BTN_HEIGHT	    ; eax = height of window
415
   imul  eax, ebx, BTN_HEIGHT	    ; eax = height of window
416
  movzx  ecx, [edi + y_end]
416
  movzx  ecx, [edi + y_end]
417
    sub  ecx, eax	    ; ecx = Y_START
417
    sub  ecx, eax	    ; ecx = Y_START
418
    shl  ecx, 16
418
    shl  ecx, 16
419
    add  ecx, eax	    ; ecx = [ Y_START | Y_SIZE ]
419
    add  ecx, eax	    ; ecx = [ Y_START | Y_SIZE ]
420
    dec  ecx
420
    dec  ecx
421
  movzx  ebx, [edi + x_start]
421
  movzx  ebx, [edi + x_start]
422
    shl  ebx, 16
422
    shl  ebx, 16
423
    mov  bx,  140	    ; ebx = [ X_START | X_SIZE ]
423
    mov  bx,  140	    ; ebx = [ X_START | X_SIZE ]
424
    xor  eax, eax	    ; function 0 : define and draw window
424
    xor  eax, eax	    ; function 0 : define and draw window
425
    mov  edx, 0x01000000       ; color of work area RRGGBB,8->color gl
425
    mov  edx, 0x01000000       ; color of work area RRGGBB,8->color gl
426
    mov  esi, edx	    ; unmovable window
426
    mov  esi, edx	    ; unmovable window
427
    int  0x40
427
    mcall
428
 
428
 
429
    call draw_all_buttons
429
    call draw_all_buttons
430
 
430
 
431
    mov  eax,12
431
    mov  eax,12
432
    mov  ebx,2
432
    mov  ebx,2
433
    int  0x40
433
    mcall
434
 
434
 
435
    ret
435
    ret
436
 
436
 
437
 
437
 
438
 draw_all_buttons:
438
 draw_all_buttons:
439
    xor  edx, edx
439
    xor  edx, edx
440
  .new_button:
440
  .new_button:
441
    call draw_one_button
441
    call draw_one_button
442
    inc  edx
442
    inc  edx
443
    cmp  dl, [edi + rows]
443
    cmp  dl, [edi + rows]
444
    jb	   .new_button
444
    jb	   .new_button
445
 
445
 
446
    ret
446
    ret
447
 
447
 
448
 
448
 
449
 draw_only_needed_buttons:
449
 draw_only_needed_buttons:
450
    xor  edx, edx
450
    xor  edx, edx
451
    mov  dl, [edi + cur_sel]
451
    mov  dl, [edi + cur_sel]
452
    dec  dl
452
    dec  dl
453
    call draw_one_button
453
    call draw_one_button
454
    mov  dl, [edi + prev_sel]
454
    mov  dl, [edi + prev_sel]
455
    dec  dl
455
    dec  dl
456
    call draw_one_button
456
    call draw_one_button
457
    ret
457
    ret
458
 
458
 
459
 
459
 
460
 draw_one_button:
460
 draw_one_button:
461
 ; receives number of button in dl
461
 ; receives number of button in dl
462
    push edx;ad
462
    push edx;ad
463
 
463
 
464
    mov  eax, 8
464
    mov  eax, 8
465
    mov  ebx, 140
465
    mov  ebx, 140
466
  movzx  ecx, dl
466
  movzx  ecx, dl
467
    imul ecx, BTN_HEIGHT
467
    imul ecx, BTN_HEIGHT
468
    shl  ecx, 16
468
    shl  ecx, 16
469
    add  ecx, BTN_HEIGHT-1
469
    add  ecx, BTN_HEIGHT-1
470
;   edx = button identifier
470
;   edx = button identifier
471
    mov  esi, [sc.work]
471
    mov  esi, [sc.work]
472
    cmp  esi, 0xdfdfdf
472
    cmp  esi, 0xdfdfdf
473
    jb   nocorrect
473
    jb   nocorrect
474
    sub  esi, 0x1b1b1b
474
    sub  esi, 0x1b1b1b
475
  nocorrect: 
475
  nocorrect: 
476
    inc  dl
476
    inc  dl
477
    cmp  [edi + cur_sel], dl
477
    cmp  [edi + cur_sel], dl
478
    jne  .nohighlight
478
    jne  .nohighlight
479
    add  esi, 0x1a1a1a
479
    add  esi, 0x1a1a1a
480
  .nohighlight:
480
  .nohighlight:
481
    or	   edx, 0x20000000
481
    or	   edx, 0x20000000
482
    int  0x40
482
    mcall
483
    movzx edx, dl
483
    movzx edx, dl
484
 
484
 
485
    dec  dl
485
    dec  dl
486
    imul ebx, edx, BTN_HEIGHT
486
    imul ebx, edx, BTN_HEIGHT
487
    add  ebx, (4 shl 16) + TXT_Y
487
    add  ebx, (4 shl 16) + TXT_Y
488
 
488
 
489
  movzx  ecx, dl
489
  movzx  ecx, dl
490
    inc  ecx
490
    inc  ecx
491
    mov  edx, [edi + pointer]
491
    mov  edx, [edi + pointer]
492
  .findline:
492
  .findline:
493
    cmp  byte [edx], 13
493
    cmp  byte [edx], 13
494
    je	   .linefound
494
    je	   .linefound
495
    inc  edx
495
    inc  edx
496
    jmp  .findline
496
    jmp  .findline
497
  .linefound:
497
  .linefound:
498
    inc  edx
498
    inc  edx
499
    cmp  byte [edx], 10
499
    cmp  byte [edx], 10
500
    jne  .findline
500
    jne  .findline
501
    dec  ecx
501
    dec  ecx
502
    jnz  .findline
502
    jnz  .findline
503
 
503
 
504
    mov  ecx, [sc.work_text]
504
    mov  ecx, [sc.work_text]
505
    mov  eax, 4
505
    mov  eax, 4
506
    mov  esi, 21
506
    mov  esi, 21
507
    int  0x40
507
    mcall
508
 
508
 
509
    pop  edx;ad
509
    pop  edx;ad
510
    ret
510
    ret
511
 
511
 
512
 
512
 
513
 searchstartstring:
513
 searchstartstring:
514
    mov  ecx, 40
514
    mov  ecx, 40
515
    mov  al, 13
515
    mov  al, 13
516
    cld
516
    cld
517
  repne  scasb
517
  repne  scasb
518
    cmp  byte [edi], 10
518
    cmp  byte [edi], 10
519
    jne  searchstartstring
519
    jne  searchstartstring
520
    ret
520
    ret
521
 
521
 
522
 
522
 
523
;*** DATA AREA ****************************************************************
523
;*** DATA AREA ****************************************************************
524
 
524
 
525
thread_stack   dd   0xE000
525
thread_stack   dd   0xE000
526
processes      dd   0
526
processes      dd   0
527
 
527
 
528
fileinfo:
528
fileinfo:
529
 .subfunction	 dd   0 	      ; 0=READ
529
 .subfunction	 dd   0 	      ; 0=READ
530
 .start 	 dd   0 	      ; start byte
530
 .start 	 dd   0 	      ; start byte
531
 .size_high	 dd   0 	      ; rezerved
531
 .size_high	 dd   0 	      ; rezerved
532
 .size		 dd   0x10000-mem_end ; blocks to read
532
 .size		 dd   0x10000-mem_end ; blocks to read
533
 .return	 dd   mem_end	      ; return data pointer
533
 .return	 dd   mem_end	      ; return data pointer
534
 .name:
534
 .name:
535
     db   '/RD/1/MENU.DAT',0   ; ASCIIZ dir & filename
535
     db   '/RD/1/MENU.DAT',0   ; ASCIIZ dir & filename
536
 
536
 
537
fileinfo_start:
537
fileinfo_start:
538
 .subfunction	 dd   7 	 ; 7=START APPLICATION
538
 .subfunction	 dd   7 	 ; 7=START APPLICATION
539
 .flags 	 dd   0 	 ; flags
539
 .flags 	 dd   0 	 ; flags
540
 .params	 dd   0x0	 ; nop
540
 .params	 dd   0x0	 ; nop
541
 .rezerved	 dd   0x0	 ; nop
541
 .rezerved	 dd   0x0	 ; nop
542
 .rezerved_1	 dd   0x0	 ; nop
542
 .rezerved_1	 dd   0x0	 ; nop
543
 .name:
543
 .name:
544
   times 50 db ' '
544
   times 50 db ' '
545
 
545
 
546
I_END:
546
I_END:
547
 
547
 
548
close_now      dd ?   ; close all processes immediately
548
close_now      dd ?   ; close all processes immediately
549
end_pointer    dd ?
549
end_pointer    dd ?
550
buffer		 dd ?
550
buffer		 dd ?
551
mousemask      dd ?   ; mask for mouse pointer location
551
mousemask      dd ?   ; mask for mouse pointer location
552
 
552
 
553
sc system_colors
553
sc system_colors
554
 
554
 
555
menu_data:
555
menu_data:
556
  rb 0x4000  ;x10000
556
  rb 0x4000  ;x10000
557
 
557
 
558
virtual at 0	      ; PROCESSES TABLE (located at menu_data)
558
virtual at 0	      ; PROCESSES TABLE (located at menu_data)
559
  pointer      dd ?   ; +0    pointer in file
559
  pointer      dd ?   ; +0    pointer in file
560
  rows		 db ?	; +4    numer of strings
560
  rows		 db ?	; +4    numer of strings
561
  x_start      dw ?   ; +5    x start
561
  x_start      dw ?   ; +5    x start
562
  y_end        dw ?   ; +7    y end
562
  y_end        dw ?   ; +7    y end
563
  child        db ?   ; +9    id of child menu
563
  child        db ?   ; +9    id of child menu
564
  parent       db ?   ; +10   id of parent menu
564
  parent       db ?   ; +10   id of parent menu
565
  cur_sel      db ?   ; +11   current selection
565
  cur_sel      db ?   ; +11   current selection
566
  prev_sel     db ?   ; +12   previous selection
566
  prev_sel     db ?   ; +12   previous selection
567
  rb	       16-$+1 ; [16 bytes per element]
567
  rb	       16-$+1 ; [16 bytes per element]
568
end virtual
568
end virtual
569
 
569
 
570
mem_end:
570
mem_end: