Subversion Repositories Kolibri OS

Rev

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

Rev 331 Rev 485
Line 16... Line 16...
16
 dd	I_END+0x10000 ; required memory
16
 dd	I_END+0x10000 ; required memory
17
 dd	I_END+0x10000 ; esp
17
 dd	I_END+0x10000 ; esp
18
 dd	0x0 , 0x0     ; I_Param , I_Path
18
 dd	0x0 , 0x0     ; I_Param , I_Path
Line 19... Line 19...
19
 
19
 
20
include 'lang.inc'
20
include 'lang.inc'
Line 21... Line 21...
21
include 'macros.inc'
21
include '..\..\..\macros.inc'
22
   
22
   
Line 23... Line 23...
23
delay	   dd  145
23
delay	   dd  145
Line 24... Line 24...
24
wait_for   dd  0x0
24
wait_for   dd  0x0
25
   
25
   
Line -... Line 26...
-
 
26
START:				; start of execution
26
START:				; start of execution
27
   
Line 27... Line 28...
27
   
28
    mov  dword [prompt], p9
Line 28... Line 29...
28
    mov  dword [prompt], p9
29
    mov  dword [promptlen], p9len - p9
29
    mov  dword [promptlen], p9len - p9
30
 
Line 30... Line 31...
30
   
31
red:   
31
    call draw_window		; at first, draw the window
32
    call draw_window		; at first, draw the window
32
   
33
   
33
still:
34
still:
34
   
35
   
35
    mov  eax,10 		; wait here for event
36
    mov  eax,10 		; wait here for event
Line 36... Line 37...
36
    int  0x40
37
    mcall
37
   
-
 
38
    cmp  eax,1			; redraw request ?
-
 
39
    jz	 red
-
 
40
    cmp  eax,2			; key in buffer ?
-
 
41
    jz	 key
-
 
42
    cmp  eax,3			; button in buffer ?
38
   
43
    jz	 button
39
    cmp  eax,1			; redraw request ?
44
   
40
    jz	 red
45
    jmp  still
41
    cmp  eax,2			; key in buffer ?
Line 46... Line 42...
46
   
42
    jz	 key
47
red:			       ; redraw
43
    cmp  eax,3			; button in buffer ?
48
    call draw_window
44
    jz	 button
Line 49... Line 45...
49
    jmp  still
45
   
50
   
46
    jmp  still
Line 51... Line 47...
51
key:			       ; Keys are not valid at this part of the
47
key:			       ; Keys are not valid at this part of the
52
    mov  eax,2			; loop. Just read it and ignore
48
    mov  eax,2			; loop. Just read it and ignore
53
    int  0x40
49
    mcall
54
    jmp  still
50
    jmp  still
55
   
51
   
Line 56... Line 52...
56
button: 		       ; button
52
button: 		       ; button
Line 57... Line 53...
57
    mov  eax,17 		; get id
53
    mov  eax,17 		; get id
58
    int  0x40
54
    mcall
Line 59... Line 55...
59
   
55
   
60
    cmp  ah,1			; button id=1 ?
56
    cmp  ah,1			; button id=1 ?
61
    jnz  noclose
57
    jnz  noclose
Line 117... Line 113...
117
   
113
   
Line 118... Line 114...
118
    mov  edi,[addr]
114
    mov  edi,[addr]
119
   
115
   
120
  f11:
116
  f11:
121
    mov  eax,10
117
    mov  eax,10
122
    int  0x40
118
    mcall
123
    cmp  eax,2
119
    cmp  eax,2
124
    jz	 fbu
120
    jz	 fbu
125
    jmp  still
121
    jmp  still
126
  fbu:
122
  fbu:
127
    mov  eax,2
123
    mov  eax,2
128
    int  0x40  ; get key
124
    mcall  ; get key
129
    shr  eax,8
125
    shr  eax,8
130
    cmp  eax,8
126
    cmp  eax,8
131
    jnz  nobs
127
    jnz  nobs
Line 160... Line 156...
160
    mov  ebx,103*65536+15*6
156
    mov  ebx,103*65536+15*6
161
    mov  ecx,[ya]
157
    mov  ecx,[ya]
162
    shl  ecx,16
158
    shl  ecx,16
163
    mov  cx,8
159
    mov  cx,8
164
    mov  edx,0x224466
160
    mov  edx,0x224466
165
    int  0x40
161
    mcall
Line 166... Line 162...
166
   
162
   
167
    mov  eax,4
163
    mov  eax,4
168
    mov  ebx,103*65536
164
    mov  ebx,103*65536
169
    add  ebx,[ya]
165
    add  ebx,[ya]
170
    mov  ecx,0xffffff
166
    mov  ecx,0xffffff
171
    mov  edx,[addr]
167
    mov  edx,[addr]
172
    mov  esi,15
168
    mov  esi,15
Line 173... Line 169...
173
    int  0x40
169
    mcall
Line 174... Line 170...
174
   
170
   
Line 307... Line 303...
307
 mov  eax,0x20000-512
303
 mov  eax,0x20000-512
308
 mov  [fileposition], eax
304
 mov  [fileposition], eax
Line 309... Line 305...
309
   
305
   
310
 ; Get a random # for the local socket port #
306
 ; Get a random # for the local socket port #
311
 mov  eax, 3
307
 mov  eax, 3
312
 int  0x40
308
 mcall
313
 mov  ecx, eax
309
 mov  ecx, eax
Line 314... Line 310...
314
 shr  ecx, 8	; Set up the local port # with a random #
310
 shr  ecx, 8	; Set up the local port # with a random #
315
   
311
   
316
   ; open socket
312
   ; open socket
317
 mov  eax, 53
313
 mov  eax, 53
318
 mov  ebx, 0
314
 mov  ebx, 0
319
 mov  edx, 69	 ; remote port
315
 mov  edx, 69	 ; remote port
Line 320... Line 316...
320
 mov  esi, [tftp_IP]  ; remote IP ( in intenet format )
316
 mov  esi, [tftp_IP]  ; remote IP ( in intenet format )
Line 321... Line 317...
321
 int  0x40
317
 mcall
Line 322... Line 318...
322
   
318
   
323
 mov  [socketNum], eax
319
 mov  [socketNum], eax
324
   
320
   
325
 ; make sure there is no data in the socket - there shouldn't be..
321
 ; make sure there is no data in the socket - there shouldn't be..
326
   
322
   
Line 327... Line 323...
327
cfr001:
323
cfr001:
328
 mov  eax, 53
324
 mov  eax, 53
329
 mov  ebx, 3
325
 mov  ebx, 3
330
 mov  ecx, [socketNum]
326
 mov  ecx, [socketNum]
Line 331... Line 327...
331
 int  0x40    ; read byte
327
 mcall    ; read byte
332
   
328
   
Line 333... Line 329...
333
 mov  eax, 53
329
 mov  eax, 53
334
 mov  ebx, 2
330
 mov  ebx, 2
335
 mov  ecx, [socketNum]
331
 mov  ecx, [socketNum]
336
 int  0x40    ; any more data?
332
 mcall    ; any more data?
337
   
333
   
338
 cmp  eax, 0
334
 cmp  eax, 0
339
 jne  cfr001	; yes, so get it
335
 jne  cfr001	; yes, so get it
Line 340... Line 336...
340
   
336
   
Line 341... Line 337...
341
 ; Now, request the file
337
 ; Now, request the file
342
 mov  eax, 53
338
 mov  eax, 53
343
 mov  ebx, 4
339
 mov  ebx, 4
Line 344... Line 340...
344
 mov  ecx, [socketNum]
340
 mov  ecx, [socketNum]
345
 mov  edx, [tftp_len]
341
 mov  edx, [tftp_len]
346
 mov  esi, tftp_filename
342
 mov  esi, tftp_filename
347
 int  0x40
343
 mcall
Line 361... Line 357...
361
   
357
   
362
    ; Any data to fetch?
358
    ; Any data to fetch?
363
 mov  eax, 53
359
 mov  eax, 53
364
 mov  ebx, 2
360
 mov  ebx, 2
365
 mov  ecx, [socketNum]
361
 mov  ecx, [socketNum]
Line 366... Line 362...
366
 int   0x40
362
 mcall
367
   
363
   
Line 368... Line 364...
368
 cmp  eax, 0
364
 cmp  eax, 0
Line 383... Line 379...
383
   
379
   
384
 ; read first two bytes - opcode
380
 ; read first two bytes - opcode
385
 mov  eax, 53
381
 mov  eax, 53
386
 mov  ebx, 3
382
 mov  ebx, 3
387
 mov  ecx, [socketNum]
383
 mov  ecx, [socketNum]
Line 388... Line 384...
388
 int  0x40   ; read byte
384
 mcall   ; read byte
389
   
385
   
390
 mov  eax, 53
386
 mov  eax, 53
391
 mov  ebx, 3
387
 mov  ebx, 3
Line 392... Line 388...
392
 mov  ecx, [socketNum]
388
 mov  ecx, [socketNum]
393
 int  0x40   ; read byte
389
 mcall   ; read byte
Line 394... Line 390...
394
   
390
   
Line 402... Line 398...
402
   
398
   
403
 ; do data stuff. Read block #. Read data. Send Ack.
399
 ; do data stuff. Read block #. Read data. Send Ack.
404
 mov  eax, 53
400
 mov  eax, 53
405
 mov  ebx, 3
401
 mov  ebx, 3
406
 mov  ecx, [socketNum]
402
 mov  ecx, [socketNum]
Line 407... Line 403...
407
 int  0x40   ; read byte
403
 mcall   ; read byte
Line 408... Line 404...
408
   
404
   
409
 mov  [blockNumber], bl
405
 mov  [blockNumber], bl
410
   
406
   
411
 mov  eax, 53
407
 mov  eax, 53
Line 412... Line 408...
412
 mov  ebx, 3
408
 mov  ebx, 3
Line 413... Line 409...
413
 mov  ecx, [socketNum]
409
 mov  ecx, [socketNum]
414
 int  0x40   ; read byte
410
 mcall   ; read byte
415
   
411
   
416
 mov  [blockNumber+1], bl
412
 mov  [blockNumber+1], bl
417
   
413
   
Line 418... Line 414...
418
cfr007:
414
cfr007:
419
 mov  eax, 53
415
 mov  eax, 53
420
 mov  ebx, 3
416
 mov  ebx, 3
421
 mov  ecx, [socketNum]
417
 mov  ecx, [socketNum]
Line 422... Line 418...
422
 int  0x40   ; read byte
418
 mcall   ; read byte
423
   
419
   
424
 mov  esi, [fileposition]
420
 mov  esi, [fileposition]
425
 mov  [esi], bl
421
 mov  [esi], bl
Line 426... Line 422...
426
 mov  [esi+1],bl
422
 mov  [esi+1],bl
427
 add  dword [fileposition],2
423
 add  dword [fileposition],2
Line 428... Line 424...
428
   
424
   
Line 440... Line 436...
440
wait_more:
436
wait_more:
Line 441... Line 437...
441
   
437
   
442
 mov  eax,5    ; wait for correct timer position
438
 mov  eax,5    ; wait for correct timer position
443
	       ; to trigger new play block
439
	       ; to trigger new play block
444
 mov  ebx,1
440
 mov  ebx,1
Line 445... Line 441...
445
 int  0x40
441
 mcall
446
   
442
   
447
 mov  eax,26
443
 mov  eax,26
Line 448... Line 444...
448
 mov  ebx,9
444
 mov  ebx,9
449
 int  0x40
445
 mcall
Line 450... Line 446...
450
   
446
   
Line 461... Line 457...
461
 rep  movsb
457
 rep  movsb
Line 462... Line 458...
462
   
458
   
463
 mov  eax,55
459
 mov  eax,55
464
 mov  ebx,0
460
 mov  ebx,0
465
 mov  ecx,0x10000
461
 mov  ecx,0x10000
Line 466... Line 462...
466
 int  0x40
462
 mcall
467
   
463
   
468
 mov  eax,55
464
 mov  eax,55
Line 469... Line 465...
469
 mov  ebx,1
465
 mov  ebx,1
Line 470... Line 466...
470
 int  0x40
466
 mcall
Line 484... Line 480...
484
 mov  eax, 53
480
 mov  eax, 53
485
 mov  ebx, 4
481
 mov  ebx, 4
486
 mov  ecx, [socketNum]
482
 mov  ecx, [socketNum]
487
 mov  edx, ackLen - ack
483
 mov  edx, ackLen - ack
488
 mov  esi, ack
484
 mov  esi, ack
489
 int   0x40
485
 mcall
Line 490... Line 486...
490
   
486
   
491
 ; If # of chars in the frame is less that 516,
487
 ; If # of chars in the frame is less that 516,
492
 ; this frame is the last
488
 ; this frame is the last
493
 pop  eax
489
 pop  eax
Line 498... Line 494...
498
 mov  eax, 33
494
 mov  eax, 33
499
 mov  ebx, source
495
 mov  ebx, source
500
 mov  edx, [filesize]
496
 mov  edx, [filesize]
501
 mov  ecx, I_END + 512
497
 mov  ecx, I_END + 512
502
 mov  esi, 0
498
 mov  esi, 0
503
 int  0x40
499
 mcall
Line 504... Line 500...
504
   
500
   
Line 505... Line 501...
505
 jmp  cfrexit
501
 jmp  cfrexit
506
   
502
   
507
cfrerr:
503
cfrerr:
508
 ; simple implementation on error - just read all data, and return
504
 ; simple implementation on error - just read all data, and return
509
 mov  eax, 53
505
 mov  eax, 53
510
 mov  ebx, 3
506
 mov  ebx, 3
Line 511... Line 507...
511
 mov  ecx, [socketNum]
507
 mov  ecx, [socketNum]
512
    int   0x40	  ; read byte
508
    mcall	  ; read byte
513
   
509
   
514
 mov  eax, 53
510
 mov  eax, 53
Line 515... Line 511...
515
 mov  ebx, 2
511
 mov  ebx, 2
516
 mov  ecx, [socketNum]
512
 mov  ecx, [socketNum]
Line 517... Line 513...
517
    int   0x40	  ; any more data?
513
    mcall	  ; any more data?
Line 525... Line 521...
525
    call draw_window
521
    call draw_window
526
    jmp  cfr002
522
    jmp  cfr002
Line 527... Line 523...
527
   
523
   
528
cfr004: 			; key pressed
524
cfr004: 			; key pressed
529
    mov  eax,2			; just read it and ignore
525
    mov  eax,2			; just read it and ignore
530
    int  0x40
526
    mcall
Line 531... Line 527...
531
    jmp  cfr002
527
    jmp  cfr002
532
   
528
   
533
cfr005: 		       ; button
529
cfr005: 		       ; button
Line 534... Line 530...
534
    mov  eax,17 		; get id
530
    mov  eax,17 		; get id
535
    int  0x40
531
    mcall
Line 536... Line 532...
536
   
532
   
537
    cmp  ah,1			; button id=1 ?
533
    cmp  ah,1			; button id=1 ?
538
    jne  cfr002     ; If not, ignore.
534
    jne  cfr002     ; If not, ignore.
539
   
535
   
540
cfr006:
536
cfr006:
541
    ; close socket
537
    ; close socket
Line 542... Line 538...
542
 mov  eax, 53
538
 mov  eax, 53
Line 543... Line 539...
543
 mov  ebx, 1
539
 mov  ebx, 1
544
 mov  ecx, [socketNum]
540
 mov  ecx, [socketNum]
Line 545... Line 541...
545
    int   0x40
541
    mcall
Line 546... Line 542...
546
   
542
   
547
 mov  [socketNum], dword 0
543
 mov  [socketNum], dword 0
548
   
544
   
549
    mov  eax,-1 		; close this program
545
    mov  eax,-1 		; close this program
550
    int  0x40
546
    mcall
551
   
547
   
Line 552... Line 548...
552
    jmp $
548
    jmp $
Line 553... Line 549...
553
   
549
   
554
cfrexit:
550
cfrexit:
Line 576... Line 572...
576
   
572
   
Line 577... Line 573...
577
draw_window:
573
draw_window:
578
   
574
   
579
    mov  eax,12 		   ; function 12:tell os about windowdraw
575
    mov  eax,12 		   ; function 12:tell os about windowdraw
Line 580... Line 576...
580
    mov  ebx,1			   ; 1, start of draw
576
    mov  ebx,1			   ; 1, start of draw
581
    int  0x40
577
    mcall
582
   
578
   
583
				   ; DRAW WINDOW
579
				   ; DRAW WINDOW
584
    mov  eax,0			   ; function 0 : define and draw window
580
    mov  eax,0			   ; function 0 : define and draw window
585
    mov  ebx,100*65536+230	   ; [x start] *65536 + [x size]
581
    mov  ebx,100*65536+230	   ; [x start] *65536 + [x size]
586
    mov  ecx,100*65536+170	   ; [y start] *65536 + [y size]
-
 
587
    mov  edx,0x13224466 	   ; color of work area RRGGBB
-
 
588
    mov  edi,labelt
-
 
589
    int  0x40
-
 
590
   
-
 
591
 
-
 
592
    mov  eax,8		    ; COPY BUTTON
582
    mov  ecx,100*65536+170	   ; [y start] *65536 + [y size]
593
    mov  ebx,20*65536+190
-
 
594
    mov  ecx,79*65536+15
-
 
Line 595... Line 583...
595
    mov  edx,3
583
    mov  edx,0x13224466 	   ; color of work area RRGGBB
596
    mov  esi,0x557799
584
    mov  edi,title
597
;    int  0x40
585
    mcall
598
   
586
   
599
    mov  eax,8		    ; DELETE BUTTON
587
    mov  eax,8		    ; DELETE BUTTON
600
    mov  ebx,20*65536+190
588
    mov  ebx,20*65536+190
Line 601... Line -...
601
    mov  ecx,111*65536+15
-
 
602
    mov  edx,2
589
    mov  ecx,111*65536+15
603
    mov  esi,0x557799
590
    mov  edx,2
604
    int  0x40
591
    mov  esi,0x557799
605
   
-
 
606
    mov  eax,8
592
    mcall
Line 607... Line -...
607
    mov  ebx,200*65536+10
-
 
608
    mov  ecx,34*65536+10
-
 
609
    mov  edx,4
593
   
610
    mov  esi,0x557799
594
    mov  ebx,200*65536+10
611
    int  0x40
-
 
612
   
595
    mov  ecx,34*65536+10
Line 613... Line 596...
613
    mov  eax,8
596
    mov  edx,4
614
    mov  ebx,200*65536+10
597
    mcall
615
    mov  ecx,50*65536+10
598
   
Line 640... Line 623...
640
    mov  ecx,[promptlen]
623
    mov  ecx,[promptlen]
641
    rep  movsb
624
    rep  movsb
Line 642... Line 625...
642
   
625
   
643
    ; Re-draw the screen text
626
    ; Re-draw the screen text
-
 
627
    cld
644
    cld
628
    mov  eax,4
645
    mov  ebx,25*65536+35	   ; draw info text with function 4
629
    mov  ebx,25*65536+35	   ; draw info text with function 4
646
    mov  ecx,0xffffff
630
    mov  ecx,0xffffff
647
    mov  edx,text
631
    mov  edx,text
648
    mov  esi,40
632
    mov  esi,40
649
  newline:
633
  newline:
650
    mov  eax,4
-
 
651
    int  0x40
634
    mcall
652
    add  ebx,16
635
    add  ebx,16
653
    add  edx,40
636
    add  edx,40
654
    cmp  [edx],byte 'x'
637
    cmp  [edx],byte 'x'
Line 655... Line 638...
655
    jnz  newline
638
    jnz  newline
656
   
639
   
657
   
640
   
Line 658... Line 641...
658
    mov  eax,12 		   ; function 12:tell os about windowdraw
641
    mov  eax,12 		   ; function 12:tell os about windowdraw
Line 659... Line 642...
659
    mov  ebx,2			   ; 2, end of draw
642
    mov  ebx,2			   ; 2, end of draw
Line 689... Line 672...
689
    db '                                        '
672
    db '                                        '
690
    db '                                        '
673
    db '                                        '
691
    db 'x' ; <- END MARKER, DONT DELETE
674
    db 'x' ; <- END MARKER, DONT DELETE
Line 692... Line 675...
692
   
675
   
Line 693... Line 676...
693
   
676
   
694
labelt	db   'TFTP Wave Player',0   
677
title	db   'TFTP Wave Player',0