Subversion Repositories Kolibri OS

Rev

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

Rev 109 Rev 485
Line 3... Line 3...
3
;
3
;
4
;    Compile with FASM for Menuet
4
;    Compile with FASM for Menuet
5
;
5
;
Line 6... Line 6...
6
 
6
 
7
include 'lang.inc'
7
include 'lang.inc'
Line 8... Line 8...
8
include 'macros.inc'
8
include '..\..\..\macros.inc'
Line 9... Line 9...
9
 
9
 
Line 10... Line 10...
10
use32
10
use32
11
 
11
 
12
                org     0x0
12
               org    0x0
13
 
13
 
14
                db      'MENUET00'              ; 8 byte id
14
	       db     'MENUET01'	    ; 8 byte id
-
 
15
	       dd     0x01		    ; header version
15
                dd      38                      ; required os
16
	       dd     START		    ; start of code
Line 16... Line 17...
16
                dd      START                   ; program start
17
	       dd     I_END		    ; size of image
17
                dd      I_END                   ; program image size
18
	       dd     I_END+0x8000	    ; memory for app
18
                dd      0x100000                ; required amount of memory
19
	       dd     I_END+0x8000	    ; esp
19
                dd      0x00000000              ; reserved=no extended header
20
	       dd     0x0 , 0x0 	    ; I_Param , I_Icon
Line -... Line 21...
-
 
21
 
20
 
22
 
Line 21... Line 23...
21
 
23
START:                                      ; start of execution
22
START:                                      ; start of execution
24
    mov     eax,40                          ; Report events
23
    mov     eax,40                          ; Report events
25
    mov     ebx,10000111b                   ; Stack 8 + defaults
Line 24... Line 26...
24
    mov     ebx,10000111b                   ; Stack 8 + defaults
26
    int     0x40
25
    int     0x40
27
 
26
 
28
red:                            ; redraw
27
    call    draw_window                     ; at first, draw the window
29
    call    draw_window                     ; at first, draw the window
28
 
30
 
29
still:
31
still:
Line 30... Line 32...
30
    mov     eax,10                          ; wait here for event
32
    mov     eax,10                          ; wait here for event
31
    int     0x40
-
 
32
 
-
 
33
    cmp     eax,1                           ; redraw request ?
-
 
34
    jz      red
-
 
35
    cmp     eax,2                           ; key in buffer ?
-
 
36
    jz      key
33
    mcall
37
    cmp     eax,3                           ; button in buffer ?
34
 
38
    jz      button
35
    cmp     eax,1                           ; redraw request ?
39
 
36
    jz      red
Line 40... Line 37...
40
    jmp     still
37
    cmp     eax,2                           ; key in buffer ?
41
 
38
    jz      key
42
red:                            ; redraw
39
    cmp     eax,3                           ; button in buffer ?
Line 43... Line 40...
43
    call    draw_window
40
    jz      button
44
    jmp     still
41
 
Line 45... Line 42...
45
 
42
    jmp     still
46
key:                            ; Keys are not valid at this part of the
43
key:                            ; Keys are not valid at this part of the
47
    mov     eax,2               ; loop. Just read it and ignore
44
    mov     eax,2               ; loop. Just read it and ignore
48
    int     0x40
45
    mcall
49
    jmp     still
46
    jmp     still
Line 50... Line 47...
50
 
47
 
51
button:                         ; button
48
button:                         ; button
Line 52... Line 49...
52
    mov     eax,17              ; get id
49
    mov     eax,17              ; get id
53
    int     0x40
50
    mcall
54
 
51
 
Line 244... Line 241...
244
    mov     eax, 53
241
    mov     eax, 53
245
    mov     ebx, 0
242
    mov     ebx, 0
246
    mov     ecx, 68                 ; local port dhcp client
243
    mov     ecx, 68                 ; local port dhcp client
247
    mov     edx, 67                 ; remote port - dhcp server
244
    mov     edx, 67                 ; remote port - dhcp server
248
    mov     esi, 0xffffffff         ; broadcast
245
    mov     esi, 0xffffffff         ; broadcast
249
    int     0x40
246
    mcall
Line 250... Line 247...
250
 
247
 
Line 251... Line 248...
251
    mov     [socketNum], eax
248
    mov     [socketNum], eax
252
 
249
 
Line 263... Line 260...
263
    mov     eax, 53
260
    mov     eax, 53
264
    mov     ebx, 4
261
    mov     ebx, 4
265
    mov     ecx, [socketNum]
262
    mov     ecx, [socketNum]
266
    mov     edx, [dhcpMsgLen]
263
    mov     edx, [dhcpMsgLen]
267
    mov     esi, dhcpMsg
264
    mov     esi, dhcpMsg
268
    int     0x40
265
    mcall
Line 269... Line 266...
269
 
266
 
Line 270... Line 267...
270
    ; Setup the DHCP buffer to receive response
267
    ; Setup the DHCP buffer to receive response
271
 
268
 
Line 277... Line 274...
277
    ; UI close
274
    ; UI close
278
    ; or data from remote
275
    ; or data from remote
Line 279... Line 276...
279
 
276
 
280
ctr001:
277
ctr001:
281
    mov     eax,10                 ; wait here for event
278
    mov     eax,10                 ; wait here for event
Line 282... Line 279...
282
    int     0x40
279
    mcall
283
 
280
 
284
    cmp     eax,1                  ; redraw request ?
281
    cmp     eax,1                  ; redraw request ?
285
    je      ctr003
282
    je      ctr003
Line 291... Line 288...
291
 
288
 
292
    ; Any data in the UDP receive buffer?
289
    ; Any data in the UDP receive buffer?
293
    mov     eax, 53
290
    mov     eax, 53
294
    mov     ebx, 2
291
    mov     ebx, 2
295
    mov     ecx, [socketNum]
292
    mov     ecx, [socketNum]
Line 296... Line 293...
296
    int     0x40
293
    mcall
297
 
294
 
Line 298... Line 295...
298
    cmp     eax, 0
295
    cmp     eax, 0
299
    je      ctr001
296
    je      ctr001
300
 
297
 
301
    ; we have data - this will be the response
298
    ; we have data - this will be the response
302
ctr002:
299
ctr002:
303
    mov     eax, 53
300
    mov     eax, 53
Line 304... Line 301...
304
    mov     ebx, 3
301
    mov     ebx, 3
305
    mov     ecx, [socketNum]
302
    mov     ecx, [socketNum]
306
    int     0x40                ; read byte - block (high byte)
303
    mcall                ; read byte - block (high byte)
307
 
304
 
Line 308... Line 305...
308
    ; Store the data in the response buffer
305
    ; Store the data in the response buffer
309
    mov     eax, [dhcpMsgLen]
306
    mov     eax, [dhcpMsgLen]
310
    mov     [eax], bl
307
    mov     [eax], bl
311
    inc     dword [dhcpMsgLen]
308
    inc     dword [dhcpMsgLen]
Line 312... Line 309...
312
 
309
 
313
    mov     eax, 53
310
    mov     eax, 53
Line 314... Line 311...
314
    mov     ebx, 2
311
    mov     ebx, 2
Line 363... Line 360...
363
ctr006:
360
ctr006:
364
    ; close socket
361
    ; close socket
365
    mov     eax, 53
362
    mov     eax, 53
366
    mov     ebx, 1
363
    mov     ebx, 1
367
    mov     ecx, [socketNum]
364
    mov     ecx, [socketNum]
368
    int     0x40
365
    mcall
Line 369... Line 366...
369
 
366
 
Line 370... Line 367...
370
    mov     [socketNum], dword 0xFFFF
367
    mov     [socketNum], dword 0xFFFF
Line 377... Line 374...
377
    call    draw_window
374
    call    draw_window
378
    jmp     ctr001
375
    jmp     ctr001
Line 379... Line 376...
379
 
376
 
380
ctr004:                         ; key
377
ctr004:                         ; key
381
    mov     eax,2               ; just read it and ignore
378
    mov     eax,2               ; just read it and ignore
382
    int     0x40
379
    mcall
Line 383... Line 380...
383
    jmp     ctr001
380
    jmp     ctr001
384
 
381
 
385
ctr005:                         ; button
382
ctr005:                         ; button
Line 386... Line 383...
386
    mov     eax,17              ; get id
383
    mov     eax,17              ; get id
387
    int     0x40
384
    mcall
388
 
385
 
389
    ; close socket
386
    ; close socket
390
    mov     eax, 53
387
    mov     eax, 53
Line 391... Line 388...
391
    mov     ebx, 1
388
    mov     ebx, 1
Line 392... Line 389...
392
    mov     ecx, [socketNum]
389
    mov     ecx, [socketNum]
Line 419... Line 416...
419
 
416
 
420
ipdisplay:
417
ipdisplay:
421
    mov     eax,47
418
    mov     eax,47
422
    push    ecx
419
    push    ecx
423
    movzx   ecx,byte [edi]
420
    movzx   ecx,byte [edi]
424
    int     0x40
421
    mcall
425
    pop     ecx
422
    pop     ecx
426
    add     edx,6*4*65536
423
    add     edx,6*4*65536
427
    inc     edi
424
    inc     edi
428
    cmp     edi,ecx
425
    cmp     edi,ecx
Line 475... Line 472...
475
    imul    edx,6
472
    imul    edx,6
476
    shl     edx,16
473
    shl     edx,16
477
    add     edx,1*65536+99
474
    add     edx,1*65536+99
478
    mov     ecx,[esp+20]
475
    mov     ecx,[esp+20]
479
    mov     esi,0xffffff
476
    mov     esi,0xffffff
480
    int     0x40
477
    mcall
481
    popa
478
    popa
482
    sub     ecx,4
479
    sub     ecx,4
483
    ret
480
    ret
Line 484... Line 481...
484
 
481
 
Line 485... Line 482...
485
 
482
 
486
draw_window:
483
draw_window:
487
 
484
 
488
    mov     eax,12                    ; function 12:tell os about windowdraw
485
    mov     eax,12                    ; function 12:tell os about windowdraw
489
    mov     ebx,1                     ; 1, start of draw
486
    mov     ebx,1                     ; 1, start of draw
490
    int     0x40
487
    mcall
491
                                      ; DRAW WINDOW
488
                                      ; DRAW WINDOW
492
    mov     eax,0                     ; function 0 : define and draw window
489
    mov     eax,0                     ; function 0 : define and draw window
493
    mov     ebx,100*65536+300         ; [x start] *65536 + [x size]
-
 
494
    mov     ecx,100*65536+156         ; [y start] *65536 + [y size]
-
 
495
    mov     edx,0x03224466            ; color of work area RRGGBB
-
 
496
    mov     esi,0x00334455            ; color of grab bar  RRGGBB,8->color gl
490
    mov     ebx,100*65536+300         ; [x start] *65536 + [x size]
497
    mov     edi,0x00ddeeff            ; color of frames    RRGGBB
-
 
498
    int     0x40
-
 
499
                                      ; WINDOW LABEL
-
 
500
    mov     eax,4                     ; function 4 : write text to window
-
 
501
    mov     ebx,8*65536+8             ; [x start] *65536 + [y start]
-
 
502
    mov     ecx,0x00ffffff            ; color of text RRGGBB
491
    mov     ecx,100*65536+156         ; [y start] *65536 + [y size]
Line 503... Line 492...
503
    mov     edx,labelt                ; pointer to text beginning
492
    mov     edx,0x13224466            ; color of work area RRGGBB
504
    mov     esi,labellen-labelt       ; text length
493
    mov     edi,title                 ; WINDOW LABEL
505
    int     0x40
494
    mcall
506
 
495
                                      
507
    mov     eax,8                     ; Resolve
496
    mov     eax,8                     ; Resolve
508
    mov     ebx,20*65536+90
497
    mov     ebx,20*65536+90
Line 509... Line 498...
509
    mov     ecx,127*65536+15
498
    mov     ecx,127*65536+15
510
    mov     edx,3
499
    mov     edx,3
511
    mov     esi,0x557799
500
    mov     esi,0x557799
512
    int     0x40
501
    mcall
Line 532... Line 521...
532
    mov     edi, dhcpLease
521
    mov     edi, dhcpLease
533
    call    drawDHMS
522
    call    drawDHMS
Line 534... Line 523...
534
 
523
 
535
    ; Re-draw the screen text
524
    ; Re-draw the screen text
-
 
525
    cld
536
    cld
526
    mov     eax,4
537
    mov     ebx,25*65536+35           ; draw info text with function 4
527
    mov     ebx,25*65536+35           ; draw info text with function 4
538
    mov     ecx,0xffffff
528
    mov     ecx,0xffffff
539
    mov     edx,text
529
    mov     edx,text
540
    mov     esi,40
-
 
541
 
530
    mov     esi,40
542
newline:
531
newline:
543
    mov     eax,4
-
 
544
    int     0x40
532
    mcall
545
    add     ebx,16
533
    add     ebx,16
546
    add     edx,40
534
    add     edx,40
547
    cmp     [edx],byte 'x'
535
    cmp     [edx],byte 'x'
Line 548... Line 536...
548
    jnz     newline
536
    jnz     newline
549
 
537
 
550
 
538
 
Line 551... Line 539...
551
    mov     eax,12                    ; function 12:tell os about windowdraw
539
    mov     eax,12                    ; function 12:tell os about windowdraw
Line 572... Line 560...
572
 
560
 
573
 
561
 
Line 574... Line 562...
574
dhms      db   '   d   h   m   s'
562
dhms      db   '   d   h   m   s'
575
forever   db   'Forever         '
-
 
Line 576... Line 563...
576
 
563
forever   db   'Forever         '
577
labelt:   db   'DHCP Client Test'
564
 
578
labellen:
565
title   db   'DHCP Client Test',0
579
 
566