Subversion Repositories Kolibri OS

Rev

Rev 4157 | Rev 4198 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4120 eAndrew 1
use32
2
    org     0x0
3
;-------------------------------------------------------------------------------
4
    db	    "MENUET01"
5
    dd	    1, main, __dataend, __memend, __stackend, 0, sys_path
6
;-------------------------------------------------------------------------------
7
    include "../../../macros.inc"
8
    include "../../../proc32.inc"
9
    include "../../../dll.inc"
10
    include "../../../develop/libraries/box_lib/load_lib.mac"
4157 eAndrew 11
    ;include "../../../debug.inc"
4120 eAndrew 12
 
4140 eAndrew 13
    include "DATA.INC"
14
    include "NAME.INC"
15
 
4120 eAndrew 16
    @use_library_mem	 \
17
	    mem.Alloc,	 \
18
	    mem.Free,	 \
19
	    mem.ReAlloc, \
20
	    dll.Load
21
;================================================================================
4140 eAndrew 22
main:
4120 eAndrew 23
; ==== Init ====
24
    mcall   18, 7
25
    mov     [win.psid], eax
26
 
27
    mcall   40, 100101b
28
 
29
; ==== Load libs ====
30
    load_libraries load_lib_start, load_lib_end
31
 
32
; ==== Config LibINI ====
4195 eAndrew 33
    invoke  ini.get_int, ini_data.file_name, ini_data.settings_name, ini_data.location_name, 1
4120 eAndrew 34
    mov     [dock_items.location], eax
35
 
4195 eAndrew 36
    invoke  ini.sections, ini_data.file_name, sections_callback
37
 
38
; ==== Load colors ====
4140 eAndrew 39
    mcall   48, 3, color
40
    or	    dword[color.bg],	0x10000000
41
    or	    dword[color.frame], 0x10000000
42
    or	    dword[color.text],	0x80000000
4120 eAndrew 43
 
44
; ==== Config LibIMG ====
4140 eAndrew 45
    mov     dword[fi.p00], 5
46
    mov     dword[fi.p16], buf_128
47
    mov     dword[fi.p21], img_data.file_name
48
 
49
    mcall   70, fi
50
 
51
    mov     edx, [buf_128 + 32]
52
    imul    edx, 10
53
 
54
    stdcall mem.Alloc, edx
4120 eAndrew 55
    mov     [img_data.rgb_object], eax
56
 
4140 eAndrew 57
    mov     dword[fi.p00], 0
58
    mov     dword[fi.p12], edx
59
    m2m     dword[fi.p16], dword[img_data.rgb_object]
60
    mov     dword[fi.p21], img_data.file_name
4120 eAndrew 61
 
4140 eAndrew 62
    mcall   70, fi
4120 eAndrew 63
 
64
    cmp     ebx, 0xFFFFFFFF
65
    je	    @f
66
 
67
    stdcall dword[img.decode], dword[img_data.rgb_object], ebx, 0
68
    mov     dword[img_data.object], eax
69
 
70
  ; === ALPHA ===
4195 eAndrew 71
    mov     edi, eax
72
    add     edi, 8
73
    mov     edi, [edi]
74
    imul    edi, 128
75
    sub     edi, 4
76
 
4120 eAndrew 77
    add     eax, 24
78
    mov     eax, [eax]
79
 .setalpha:
80
    mov     ebx, [eax + edi]
81
    shr     ebx, 24
82
    cmp     ebx, 0
83
    jne     .nonalpha
4134 eAndrew 84
 
85
    mov     ecx, [color.bg]
4120 eAndrew 86
    mov     [eax + edi], ecx
87
 .nonalpha:
4195 eAndrew 88
    sub     edi, 4
89
    cmp     edi, 0
4120 eAndrew 90
    jne     .setalpha
91
 
92
  ; === CONVERTING TO BGR
93
    stdcall dword[img.toRGB], dword[img_data.object], dword[img_data.rgb_object]
94
    stdcall dword[img.destroy], dword[img_data.object]
95
 
96
; ==== Config window ====
97
    mov     eax, dword[dock_items.location]
98
    and     eax, 1b
99
    cmp     eax, 0
100
    je	    .vert
101
    jmp     .setshape
102
 
103
 .vert:
104
    mov     byte[win.isvert], 1
105
 
106
 .setshape:
107
    cmp     byte[win.isvert], 1
108
    je	    .vert_sp
109
 
110
 .horz_sp:
111
    call    .HORZ_WIDTH
112
    call    .HORZ_X
113
    call    .HORZ_HEIGHT
114
    cmp     dword[dock_items.location], 1
115
    je	    .settop
116
 
117
 .setbottom:
118
    call    .HORZ_Y_BOTTOM
119
    jmp     .SETDEF
120
 
121
 .settop:
122
    call    .HORZ_Y_TOP
123
    jmp     .SETDEF
124
 
125
 
126
 .vert_sp:
127
    call    .VERT_WIDTH
128
    call    .VERT_HEIGHT
129
    call    .VERT_Y
130
    cmp     dword[dock_items.location], 2
131
    je	    .setleft
132
 
133
 .setright:
134
    call    .VERT_X_RIGHT
135
    jmp     .SETDEF
136
 
137
 .setleft:
138
    call    .VERT_X_LEFT
139
    jmp     .SETDEF
140
 
4195 eAndrew 141
;-------------------------------------------------------------------------------
4120 eAndrew 142
 .HORZ_WIDTH:
4140 eAndrew 143
    mov     eax, BUTTON_SIZE
4120 eAndrew 144
    mov     ebx, [dock_items.count]
145
    imul    eax, ebx
4140 eAndrew 146
    add     eax, 24
4120 eAndrew 147
    dec     eax
148
    mov     [win.width_opn], eax
149
    mov     [win.width_hdn], eax
150
 
151
    ret
152
 
4195 eAndrew 153
;-------------------------------------------------------------------------------
4120 eAndrew 154
 .HORZ_X:
155
    mcall   14
4195 eAndrew 156
    shr     eax, 17
157
    mov     ecx, [win.width_opn]
158
    shr     ecx, 1
159
    sub     eax, ecx
160
    mov     [win.x_opn], eax
161
    mov     [win.x_hdn], eax
4120 eAndrew 162
 
163
    ret
164
 
4195 eAndrew 165
;-------------------------------------------------------------------------------
4120 eAndrew 166
 .HORZ_HEIGHT:
4195 eAndrew 167
    mov     dword[win.height_hdn], 3
4140 eAndrew 168
    mov     dword[win.height_opn], BUTTON_SIZE
4120 eAndrew 169
 
170
    ret
171
 
4195 eAndrew 172
;-------------------------------------------------------------------------------
4120 eAndrew 173
 .HORZ_Y_BOTTOM:
174
    mcall   14
175
    and     eax, 0xFFFF
176
    dec     eax
177
    mov     [win.y_hdn], eax
4157 eAndrew 178
    sub     eax, 43
4120 eAndrew 179
    mov     [win.y_opn], eax
180
 
181
    ret
182
 
183
 .HORZ_Y_TOP:
184
    mov     dword[win.y_opn], 0
185
    mov     dword[win.y_hdn], 0
186
 
187
    ret
188
 
4195 eAndrew 189
;-------------------------------------------------------------------------------
4120 eAndrew 190
 .VERT_WIDTH:
4140 eAndrew 191
    mov     dword[win.width_opn], BUTTON_SIZE
4157 eAndrew 192
    mov     dword[win.width_hdn], 3
4120 eAndrew 193
 
194
    ret
195
 
4195 eAndrew 196
;-------------------------------------------------------------------------------
4120 eAndrew 197
 .VERT_X_LEFT:
198
    mov     dword[win.x_opn], 0
199
    mov     dword[win.x_hdn], 0
200
 
201
    ret
202
 
203
 .VERT_X_RIGHT:
204
    mcall   14
205
    and     eax, 0xFFFF0000
206
    shr     eax, 16
207
    mov     [win.x_hdn], eax
4140 eAndrew 208
    sub     eax, BUTTON_SIZE
4120 eAndrew 209
    mov     [win.x_opn], eax
210
 
211
    ret
212
 
4195 eAndrew 213
;-------------------------------------------------------------------------------
4120 eAndrew 214
 .VERT_HEIGHT:
4140 eAndrew 215
    mov     eax, BUTTON_SIZE
4120 eAndrew 216
    mov     ebx, [dock_items.count]
217
    imul    eax, ebx
218
    dec     eax
4195 eAndrew 219
    add     eax, 12
4120 eAndrew 220
    mov     [win.height_opn], eax
221
    mov     [win.height_hdn], eax
222
 
223
    ret
224
 
4195 eAndrew 225
;-------------------------------------------------------------------------------
4120 eAndrew 226
 .VERT_Y:
227
    mcall   14
228
    and     eax, 0xFFFF
4195 eAndrew 229
    shr     eax, 1
4120 eAndrew 230
 
4195 eAndrew 231
    mov     esi, [win.height_opn]
232
    shr     esi, 1
233
    sub     eax, esi
4120 eAndrew 234
 
4195 eAndrew 235
    mov     [win.y_hdn], eax
236
    mov     [win.y_opn], eax
4120 eAndrew 237
 
238
    ret
239
 
4195 eAndrew 240
;-------------------------------------------------------------------------------
4120 eAndrew 241
 .SETDEF:
242
    mov     eax, [win.width_hdn]
243
    mov     [win.width], eax
244
 
245
    mov     eax, [win.x_hdn]
246
    mov     [win.x], eax
247
 
248
    mov     eax, [win.height_hdn]
249
    mov     [win.height], eax
250
 
251
    mov     eax, [win.y_hdn]
252
    mov     [win.y], eax
253
 
4195 eAndrew 254
;-------------------------------------------------------------------------------
4120 eAndrew 255
; ==== START ====
256
    mcall   9, win.procinfo, -1
257
    mov     ecx, [win.procinfo + 30]
258
    mcall   18, 21
259
    and     eax, 0xFFFF
260
    mov     [win.sid], eax
261
 
262
    call    main_loop
4140 eAndrew 263
;-------------------------------------------------------------------------------
4120 eAndrew 264
exit:
265
    stdcall mem.Free, [img_data.rgb_object]
266
    mcall   18, 2, [nwin.sid]
267
    mcall   -1
268
;-------------------------------------------------------------------------------
4195 eAndrew 269
main_loop:
4120 eAndrew 270
    mcall   10
271
 
272
    cmp     eax, EV_REDRAW
273
    je	    event_redraw
274
 
275
    cmp     eax, EV_BUTTON
276
    je	    event_button
277
 
278
    cmp     eax, EV_MOUSE
279
    je	    event_mouse
280
 
281
    jmp     main_loop
282
;-------------------------------------------------------------------------------
4140 eAndrew 283
event_redraw:
4120 eAndrew 284
    mcall   12, 1
285
 
4195 eAndrew 286
    mov     esi, [color.bg]
287
    or	    esi, 0x01000000
288
    mcall   0, <[win.x], [win.width]>, <[win.y], [win.height]>, [color.bg], , [color.frame]
4120 eAndrew 289
 
290
    mov     edi, 0
291
  @@:
292
    cmp     edi, [dock_items.count]
293
    je	    @f
294
 
295
    push    edi
4124 eAndrew 296
    mov     eax, 8
297
    mov     edx, 0x60000002
298
    mov     esi, [color.bg]
4140 eAndrew 299
    imul    edi, BUTTON_SIZE
300
    add     edi, 12
4124 eAndrew 301
    shl     edi, 16
4140 eAndrew 302
    add     edi, BUTTON_SIZE
4120 eAndrew 303
    cmp     byte[win.isvert], 1
304
    je	    .vert_btn
4140 eAndrew 305
    mcall   , edi, <0, BUTTON_SIZE>
4120 eAndrew 306
    jmp     .endbtn
307
 .vert_btn:
4157 eAndrew 308
    sub     edi, 12 shl 16
4140 eAndrew 309
    mcall   , <0, BUTTON_SIZE>, edi
4120 eAndrew 310
 .endbtn:
311
    pop     edi
312
 
313
    cmp     byte[dock_items.separator + edi], 1
4134 eAndrew 314
    jne     .end_separator
4120 eAndrew 315
 
316
 .draw_separator:
317
    push    ebx
318
    push    ecx
4140 eAndrew 319
 
4124 eAndrew 320
    mov     eax, 13
4120 eAndrew 321
    mov     ebx, edi
4140 eAndrew 322
    imul    ebx, BUTTON_SIZE
323
    add     ebx, BUTTON_SIZE
324
    add     ebx, 12
325
    dec     ebx
4120 eAndrew 326
    shl     ebx, 16
327
    add     ebx, 1
4140 eAndrew 328
 
4120 eAndrew 329
    cmp     byte[win.isvert], 1
330
    je	    .vert_draw_sep
4140 eAndrew 331
    mcall   , , <4, 36>, [color.frame]
4120 eAndrew 332
    jmp     .end_inner_sep
333
 .vert_draw_sep:
4157 eAndrew 334
    sub     ebx, 12 shl 16
4120 eAndrew 335
    mov     ecx, ebx
4140 eAndrew 336
    mcall   , <4, 36>, , [color.frame]
4120 eAndrew 337
 .end_inner_sep:
338
    pop     ecx
339
    pop     ebx
340
 .end_separator:
341
 
342
    cmp     byte[win.isvert], 1
343
    je	    .vert_dig
344
    mov     edx, ebx
345
    and     edx, 0xFFFF0000
4140 eAndrew 346
    add     edx, 0x00060006
4120 eAndrew 347
    jmp     .digend
348
 .vert_dig:
349
    mov     edx, ecx
350
    and     edx, 0xFFFF0000
351
    shr     edx, 16
4140 eAndrew 352
    add     edx, 0x00060006
4120 eAndrew 353
 .digend:
354
 
355
    imul    ebx, edi, 4
356
    add     ebx, dock_items.icon
357
    mov     ebx, [ebx]
4140 eAndrew 358
    imul    ebx, ICON_SIZE_BGR
4120 eAndrew 359
    add     ebx, [img_data.rgb_object]
360
 
361
    mcall   7, , <32, 32>
362
 
363
    inc     edi
364
    jmp     @b
365
  @@:
366
 
4195 eAndrew 367
 ; ==== DRAW SETTINGS ====
368
    cmp     byte[win.isvert], 1
369
    je	    .cfg_vert
370
 
371
    mov     ebx, [win.width]
372
    sub     ebx, 10
373
    shl     ebx, 16
374
    add     ebx, 8
375
    mcall   8, , <2, BUTTON_SIZE - 4>, 0x60000003
376
    jmp     @f
377
 
378
 .cfg_vert:
379
    mov     ecx, [win.height]
380
    sub     ecx, 10
381
    shl     ecx, 16
382
    add     ecx, 8
383
    mcall   8, <2, BUTTON_SIZE - 4>, , 0x60000003
384
  @@:
385
 
386
 ; ==== cfg image ====
387
    mov     edi, 0
388
  @@:
389
    cmp     byte[set_img + edi], 0
390
    je	    .notdraw
391
 
392
    mov     eax, edi
393
    mov     edx, 0
394
    mov     ebx, 6
395
    div     ebx
396
    mov     ebx, edx
397
    mov     ecx, eax
398
 
399
    add     ebx, [win.width]
400
    cmp     byte[win.isvert], 0
401
    je	    .cfg_hoz
402
    sub     ebx, [win.width]
403
    add     ebx, [win.height]
404
 .cfg_hoz:
405
    sub     ebx, 10
406
    add     ecx, 18
407
 
408
    cmp     byte[win.isvert], 0
409
    je	    .cfg_draw
410
 
411
    xchg    ebx, ecx
412
 
413
  .cfg_draw:
414
    mcall   1, , , [color.frame]
415
 
416
 .notdraw:
417
    inc     edi
418
    cmp     edi, 36
419
    jne     @b
420
 
4120 eAndrew 421
    mcall   12, 2
422
 
423
    jmp     main_loop
424
;-------------------------------------------------------------------------------
4140 eAndrew 425
event_button:
4120 eAndrew 426
    mcall   17
427
 
428
    cmp     ah, 1
429
    je	    .button_close
430
 
431
    cmp     ah, 2
432
    je	    .button_dock
433
 
4195 eAndrew 434
    cmp     ah, 3
435
    je	    .button_cfg
436
 
4120 eAndrew 437
    jmp     @f
438
 
439
 .button_close:
440
    jmp     exit
441
 
442
 .button_dock:
443
    mov     edi, [win.button_index]
444
    imul    edi, 256
445
 
4140 eAndrew 446
    mov     dword[fi.p00], 7
447
 
4120 eAndrew 448
    mov     esi, edi
449
    add     esi, dock_items.path
4140 eAndrew 450
    mov     dword[fi.p21], esi
4120 eAndrew 451
 
452
    mov     esi, edi
453
    add     esi, dock_items.param
4140 eAndrew 454
    mov     dword[fi.p08], esi
4120 eAndrew 455
 
4140 eAndrew 456
    mcall   70, fi
4120 eAndrew 457
 
4134 eAndrew 458
    mov     ecx, eax
459
    mcall   18, 21
460
    and     eax, 0xFFFF
461
    mov     [win.psid], eax
462
 
4140 eAndrew 463
    jmp     wnd_hide
464
 
4195 eAndrew 465
 .button_cfg:
466
    mov     dword[fi.p00], 7
467
    mov     dword[fi.p21], cfg_app
468
    mcall   70, fi
469
 
470
    mov     ecx, eax
471
    mcall   18, 21
472
    and     eax, 0xFFFF
473
    mov     [win.psid], eax
474
 
475
    jmp     wnd_hide
476
 
4120 eAndrew 477
  @@:
478
    jmp     main_loop
479
;-------------------------------------------------------------------------------
4140 eAndrew 480
event_mouse:
4120 eAndrew 481
    mcall   37, 1
482
    mov     edi, eax
483
    mov     esi, eax
484
    shr     edi, 16
485
    and     esi, 0xFFFF
486
 
487
    cmp     edi, 0
4140 eAndrew 488
    jl	    wnd_hide
4120 eAndrew 489
    dec     edi
490
    cmp     edi, [win.width]
4140 eAndrew 491
    jg	    wnd_hide
4120 eAndrew 492
    cmp     esi, 0
4140 eAndrew 493
    jl	    wnd_hide
4120 eAndrew 494
    dec     esi
495
    cmp     esi, [win.height]
4140 eAndrew 496
    jg	    wnd_hide
4120 eAndrew 497
 
498
    mov     eax, [dock_items.location]
499
    and     eax, 1b
500
    cmp     eax, 1
501
    jne     .vert
502
    mov     eax, edi
503
    jmp     .nxt
504
 
505
 .vert:
506
    mov     eax, esi
4157 eAndrew 507
    add     eax, 12
4120 eAndrew 508
 
509
 .nxt:
4140 eAndrew 510
    sub     eax, 12
4120 eAndrew 511
    mov     edx, 0
4140 eAndrew 512
    mov     ebx, BUTTON_SIZE
4120 eAndrew 513
    div     ebx
514
 
515
    cmp     eax, [dock_items.count]
516
    jge     .set0
517
    jmp     .nxtcmp
518
 
519
 .set0:
520
    mov     eax, 100
521
 
522
 .nxtcmp:
523
    cmp     [win.button_index], eax
524
    je	    .nxt2
525
 
526
    mov     [win.button_index], eax
527
 
528
 .nxt2:
529
    mov     eax, [win.button_index]
4140 eAndrew 530
    imul    eax, BUTTON_SIZE
4120 eAndrew 531
    cmp     byte[win.isvert], 1
532
    je	    .vert_name
533
    add     eax, [win.x]
534
    mov     [nwin.x], eax
4157 eAndrew 535
    mov     byte[nwin.change_shape], 1
536
    mcall   13, <0, [win.width]>, <[win.height], 1>, [color.frame]
4120 eAndrew 537
    jmp     .vert_end
538
 .vert_name:
539
    add     eax, [win.y]
4157 eAndrew 540
    add     eax, 14
4120 eAndrew 541
    mov     [nwin.y], eax
4157 eAndrew 542
    mov     byte[nwin.change_shape], 1
543
    mcall   13, <[win.width], 1>, <0, [win.height]>, [color.frame]
4120 eAndrew 544
 .vert_end:
545
 
546
    cmp     byte[win.state], 1
4140 eAndrew 547
    je	    main_loop
4120 eAndrew 548
 
549
    mov     edx, esp
550
    add     edx, 512
551
    mcall   51, 1, n_main
552
 
4124 eAndrew 553
    mov     eax, 18
554
 
555
    mcall   , 7
4120 eAndrew 556
    mov     [win.psid], eax
557
 
4129 eAndrew 558
    mcall   18, 3, [win.sid]
4120 eAndrew 559
 
560
    mov     byte[win.state], 1
561
 
562
    mov     eax, [win.width_opn]
563
    mov     [win.width], eax
564
 
565
    mov     eax, [win.x_opn]
566
    mov     [win.x], eax
567
 
568
    mov     eax, [win.height_opn]
569
    mov     [win.height], eax
570
 
571
    mov     eax, [win.y_opn]
572
    mov     [win.y], eax
573
 
574
    mcall   67, [win.x], [win.y], [win.width], [win.height]
575
 
4140 eAndrew 576
    jmp     event_redraw
4120 eAndrew 577
 
4140 eAndrew 578
;-------------------------------------------------------------------------------
579
wnd_hide:
4120 eAndrew 580
    cmp     byte[win.state], 0
4140 eAndrew 581
    je	    main_loop
4120 eAndrew 582
 
583
    mov     byte[nwin.close], 1
584
 
585
    mcall   18, 3, [win.psid]
586
 
587
    mov     byte[win.state], 0
588
    mov     byte[win.button_index], -1
589
 
590
    mov     eax, [win.width_hdn]
591
    mov     [win.width], eax
592
 
593
    mov     eax, [win.x_hdn]
594
    mov     [win.x], eax
595
 
596
    mov     eax, [win.height_hdn]
597
    mov     [win.height], eax
598
 
599
    mov     eax, [win.y_hdn]
600
    mov     [win.y], eax
601
 
602
    mcall   67, [win.x], [win.y], [win.width], [win.height]
603
 
4140 eAndrew 604
    jmp     event_redraw
4120 eAndrew 605
;-------------------------------------------------------------------------------
606
proc sections_callback, _file_name, _section_name
607
    mov     eax, [_section_name]
608
    cmp     byte[eax], '@'
609
    jne     @f
610
 
611
    dec     dword[dock_items.count]
612
    jmp     .endproc
613
 
614
  @@:
615
    ; ==== GET NAME ====
616
    mov     ebx, [dock_items.count]
617
    imul    ebx, 16
618
    add     ebx, dock_items.name
619
 
620
    mov     eax, [_section_name]
621
 
622
    mov     edi, 0
623
  @@:
624
    mov     cl, byte[eax]
625
    mov     byte[ebx + edi], cl
626
 
627
    inc     eax
628
    inc     edi
629
    cmp     edi, 10
630
    jne     @b
631
 
632
  ; ==== GET PATH ====
633
    mov     ebx, [dock_items.count]
634
    imul    ebx, 256
635
    add     ebx, dock_items.path
636
 
637
    invoke  ini.get_str, [_file_name], [_section_name], ini_data.path_name, ebx, 256, 0
638
 
639
  ; === GET  PARAM ===
640
    mov     ebx, [dock_items.count]
641
    imul    ebx, 256
642
    add     ebx, dock_items.param
643
 
644
    invoke  ini.get_str, [_file_name], [_section_name], ini_data.param_name, ebx, 256, 0
645
 
646
  ; ==== GET ICON ====
647
    invoke  ini.get_int, [_file_name], [_section_name], ini_data.icon_name, 0
648
 
649
    mov     ebx, [dock_items.count]
650
    imul    ebx, 4
651
    mov     [dock_items.icon + ebx], eax
652
 
653
  ; ==== GET SEPARATOR ====
654
    invoke  ini.get_int, [_file_name], [_section_name], ini_data.separator_name, 0
655
 
656
    mov     ebx, [dock_items.count]
657
    mov     byte[dock_items.separator + ebx], al
658
 
659
  ; ====== END =======
660
 .endproc:
661
    mov     eax, 1
662
    inc     dword[dock_items.count]
663
    ret
664
endp
665
;-------------------------------------------------------------------------------
4140 eAndrew 666
    include "MEMORY.INC"