Subversion Repositories Kolibri OS

Rev

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

Rev 382 Rev 485
Line 1... Line 1...
1
;;   Calculator for MenuetOS (c) Ville Turjanmaa
1
;;   Calculator for MenuetOS (c) Ville Turjanmaa
2
;;  
2
;;  
3
;;   Compile with FASM for Menuet
3
;;   Compile with FASM
-
 
4
;;   
-
 
5
;;   Pavel Rymovski (Heavyiron) - version for KolibriOS
4
;;   
6
;;
5
;;  Pavel Rymovski (Heavyiron) - kolibri version
-
 
6
;; What's new:
7
;; What's new:
7
;;   Calc 1.1
8
;;   Calc 1.1
8
;;           1) changed design
9
;;           1) changed design
9
;;           2) new procedure of draw window (10 decimal digits, 23 binary, "+" not displayed now)
10
;;           2) new procedure of draw window (10 decimal digits, 23 binary, "+" not displayed now)
10
;;           3) window with skin
11
;;           3) window with skin
11
;;           4) used macroses
-
 
12
;;   Calc 1.2
12
;;   Calc 1.2
13
;;           1)added some useful functions, such as arcsin, arccos, arctg, 1/x, x^2
13
;;           1)added some useful functions, such as arcsin, arccos, arctg, 1/x, x^2
14
;;   Calc 1.31
14
;;   Calc 1.31
15
;;           1)optimised program
15
;;           1)optimised program
16
;;           2)new type of window (you need kernel 114 revision or higher)
16
;;           2)new type of window (you need kernel 114 revision or higher)
Line 29... Line 29...
29
               dd     I_END                    ; size of image
29
               dd     I_END                    ; size of image
30
               dd     0x1000                  ; memory for app
30
               dd     0x1000                  ; memory for app
31
               dd     0x1000                  ; esp
31
               dd     0x1000                  ; esp
32
               dd     0x0,0x0                 ; I_Param , I_Icon
32
               dd     0x0,0x0                 ; I_Param , I_Icon
Line 33... Line 33...
33
 
33
 
Line 34... Line 34...
34
include 'macros.inc'
34
include '..\..\..\macros.inc'
Line 35... Line 35...
35
 
35
 
36
START:
36
START:
37
 
37
 
38
    mov  eax,48
38
    mov  eax,48
39
    mov  ebx,3
39
    mov  ebx,3
Line 40... Line 40...
40
    mov  ecx,sc
40
    mov  ecx,sc
41
    mov  edx,sizeof.system_colors
41
    mov  edx,sizeof.system_colors
Line 42... Line 42...
42
    int  0x40
42
    mcall
43
 
43
 
44
red:
44
 red:
45
    call draw_window
45
    call draw_window
-
 
46
 
46
 
47
 still:  
47
still:  
48
    push 10 
48
    push 10 
49
    pop eax 
49
    pop eax 
50
    mcall
Line 50... Line 51...
50
    int 40h 
51
 
51
    dec eax 
52
    dec eax
52
    jz red
53
    jz red
53
    dec eax 
54
    dec eax 
54
    jz key 
55
    jz key 
Line 55... Line 56...
55
 
56
 
56
button:
57
  button:
57
    mov  al,17      ; ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
58
    mov  al,17      ; ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
58
    int  0x40
59
    mcall
59
    shr  eax,8
60
    shr  eax,8
60
    jmp  testbut
61
    jmp  testbut
61
 
62
 
62
key:         
63
  key:         
Line 76... Line 77...
76
     
77
     
77
  testbut:
78
  testbut:
78
    cmp  eax,1      ; ª­®¯ª  1 - § ªàë⨥ ¯à®£à ¬¬ë
79
    cmp  eax,1      ; ª­®¯ª  1 - § ªàë⨥ ¯à®£à ¬¬ë
79
    jne  noclose
80
    jne  noclose
80
    or   eax,-1
81
    or   eax,-1
Line 81... Line 82...
81
    int  0x40 
82
    mcall 
82
 
83
 
83
  noclose:
84
  noclose:
84
    cmp  eax,2
85
    cmp  eax,2
Line 647... Line 648...
647
 
648
 
Line 648... Line 649...
648
draw_window:
649
draw_window:
649
    
650
    
650
    mov  eax,12
651
    mov  eax,12
Line 651... Line 652...
651
    mov  ebx,1
652
    mov  ebx,1
652
    int  0x40
653
    mcall
653
                                   
654
                                   
654
    xor  eax,eax                     
655
    xor  eax,eax                     
655
    mov  ebx,200 shl 16+255        
656
    mov  ebx,200 shl 16+255        
656
    mov  ecx,200 shl 16+180
657
    mov  ecx,200 shl 16+180
657
    mov  edx,[sc.work]
658
    mov  edx,[sc.work]
Line 658... Line 659...
658
    or   edx,0x33000000
659
    or   edx,0x33000000
659
    mov  edi,header
660
    mov  edi,title
660
    int  0x40
661
    mcall
661
 
662
 
Line 670... Line 671...
670
    jnz  no_new_row
671
    jnz  no_new_row
671
    mov  edi,7
672
    mov  edi,7
672
    mov  ebx,19 shl 16+28
673
    mov  ebx,19 shl 16+28
673
    add  ecx,20 shl 16
674
    add  ecx,20 shl 16
674
  no_new_row:
675
  no_new_row:
675
    int  0x40
676
    mcall
676
    add  ebx,30 shl 16
677
    add  ebx,30 shl 16
677
    inc  edx
678
    inc  edx
678
    cmp  edx,39
679
    cmp  edx,39
679
    jbe  newbutton
680
    jbe  newbutton
Line 685... Line 686...
685
    mov  ebx,27 shl 16+54
686
    mov  ebx,27 shl 16+54
686
    mov  ecx,[sc.work_button_text]
687
    mov  ecx,[sc.work_button_text]
687
    mov  edx,text
688
    mov  edx,text
688
    mov  esi,33
689
    mov  esi,33
689
  newline:
690
  newline:
690
    int  0x40
691
    mcall
691
    add  ebx,20
692
    add  ebx,20
692
    add  edx,33
693
    add  edx,33
693
    cmp  [edx],byte 'x'
694
    cmp  [edx],byte 'x'
694
    jne  newline
695
    jne  newline
Line 695... Line 696...
695
    
696
    
Line 696... Line 697...
696
    call print_display
697
    call print_display
697
    
698
    
698
    mov  eax,12
699
    mov  eax,12
Line 699... Line 700...
699
    mov  ebx,2
700
    mov  ebx,2
Line 700... Line 701...
700
    int  0x40
701
    mcall
701
 
702
 
Line 710... Line 711...
710
    mov  ecx,[sc.work_text]
711
    mov  ecx,[sc.work_text]
711
    or   ecx,0x40000000
712
    or   ecx,0x40000000
712
    mov  edx,calc
713
    mov  edx,calc
713
    mov  esi,1
714
    mov  esi,1
714
    mov  edi,[sc.work]
715
    mov  edi,[sc.work]
715
    int  0x40
716
    mcall
Line 716... Line 717...
716
 
717
 
717
    mov  ebx,198 shl 16+8
718
    mov  ebx,198 shl 16+8
718
    mov  edx,[display_type]
719
    mov  edx,[display_type]
719
    shl  edx,2
720
    shl  edx,2
720
    add  edx,display_type_text
721
    add  edx,display_type_text
721
    mov  esi,3
722
    mov  esi,3
722
    mov  edi,[sc.work]
723
    mov  edi,[sc.work]
Line 723... Line 724...
723
    int  0x40
724
    mcall
724
   
725
   
725
    cmp  [dsign],byte '+'
726
    cmp  [dsign],byte '+'
726
    je   positive
727
    je   positive
727
    mov  ebx,23 shl 16+22
728
    mov  ebx,23 shl 16+22
728
    mov  ecx,0x0
729
    mov  ecx,0x0
729
    mov  edx,dsign
730
    mov  edx,dsign
Line 730... Line 731...
730
    mov  esi,1
731
    mov  esi,1
731
    int  0x40  
732
    mcall  
732
 
733
 
733
positive:  
734
positive:  
Line 738... Line 739...
738
 
739
 
739
    mov  ebx,180 shl 16+22
740
    mov  ebx,180 shl 16+22
740
    mov  ecx,0x0
741
    mov  ecx,0x0
741
    mov  edx,dot
742
    mov  edx,dot
742
    mov  esi,1
743
    mov  esi,1
Line 743... Line 744...
743
    int  0x40
744
    mcall
744
    
745
    
745
    mov  eax,47
746
    mov  eax,47
746
    mov  ebx,10 shl 16
747
    mov  ebx,10 shl 16
747
    mov  ecx,[integer]
748
    mov  ecx,[integer]
748
    mov  edx,120 shl 16+22
749
    mov  edx,120 shl 16+22
Line 749... Line 750...
749
    mov  esi,0x0
750
    mov  esi,0x0
750
    int  0x40     
751
    mcall     
751
    
752
    
752
    mov  ebx,6 shl 16
753
    mov  ebx,6 shl 16
753
    mov  ecx,[decimal]
754
    mov  ecx,[decimal]
Line 754... Line 755...
754
    mov  edx,187 shl 16+22     
755
    mov  edx,187 shl 16+22     
755
    mov  esi,0x0
756
    mov  esi,0x0
Line 756... Line 757...
756
    int  0x40 
757
    mcall 
757
 
758
 
758
    popa
759
    popa
759
    ret
760
    ret
760
    
761
    
761
whole:
762
whole:
Line 762... Line 763...
762
    mov  ebx,220 shl 16+22
763
    mov  ebx,220 shl 16+22
763
    mov  ecx,0x0
764
    mov  ecx,0x0
Line 764... Line 765...
764
    mov  edx,dot
765
    mov  edx,dot
765
    mov  esi,1
766
    mov  esi,1
766
    int  0x40
767
    mcall
767
 
768
 
768
    cmp  [integer],0
769
    cmp  [integer],0
769
    je  null
770
    je  null
Line 770... Line 771...
770
 
771
 
771
    mov  eax,47
772
    mov  eax,47
Line 772... Line 773...
772
    mov  ebx,10 shl 16
773
    mov  ebx,10 shl 16
Line 787... Line 788...
787
    mov  eax,47
788
    mov  eax,47
788
    mov  ebx,256+8 shl 16
789
    mov  ebx,256+8 shl 16
789
    mov  ecx,[integer]
790
    mov  ecx,[integer]
790
    mov  edx,173 shl 16+22
791
    mov  edx,173 shl 16+22
791
    mov  esi,0x0
792
    mov  esi,0x0
792
    int  0x40
793
    mcall
Line 793... Line 794...
793
 
794
 
794
    popa
795
    popa
Line 795... Line 796...
795
    ret
796
    ret
Line 801... Line 802...
801
    mov  eax,47
802
    mov  eax,47
802
    mov  ebx,2*256+32 shl 16
803
    mov  ebx,2*256+32 shl 16
803
    mov  ecx,[integer]
804
    mov  ecx,[integer]
804
    mov  edx,32 shl 16+22
805
    mov  edx,32 shl 16+22
805
    mov  esi,0x0
806
    mov  esi,0x0
806
    int  0x40
807
    mcall
Line 807... Line 808...
807
 
808
 
808
    popa
809
    popa
Line 809... Line 810...
809
    ret
810
    ret
810
  
811
  
811
  null:
812
  null:
812
    mov  eax,47
813
    mov  eax,47
813
    mov  ebx,1 shl 16
814
    mov  ebx,1 shl 16
814
    mov  ecx,0
815
    mov  ecx,0
815
    mov  edx,214 shl 16+22
816
    mov  edx,214 shl 16+22
Line 816... Line 817...
816
    mov  esi,0x0
817
    mov  esi,0x0
817
    int  0x40
818
    mcall
Line 818... Line 819...
818
 
819
 
Line 841... Line 842...
841
    ret
842
    ret
Line 842... Line 843...
842
 
843
 
Line 843... Line 844...
843
 
844
 
Line 844... Line 845...
844
;data
845
;data
845
 
846
 
846
header db appname,version,0
847
title db appname,version,0