16,11 → 16,10 |
;; 2)new type of window (you need kernel 114 revision or higher) |
;; Calc 1.32 |
;; 1)fixed arccos |
;; Calc 1.33 |
;; 1) align button captions in proper way, finally! |
|
|
appname equ 'Calc ' |
version equ '1.32' |
|
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
27,21 → 26,17 |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd 0x1000 ; memory for app |
dd 0x1000 ; esp |
dd E_END ; memory for app |
dd E_END ; esp |
dd 0x0,0x0 ; I_Param , I_Icon |
|
include '..\..\..\macros.inc' |
include '../../../macros.inc' |
|
START: |
|
red: |
call draw_window |
|
still: |
push 10 |
pop eax |
mcall |
mcall 10 |
|
dec eax |
jz red |
49,16 → 44,14 |
jz key |
|
button: |
mov al,17 ; ¯®«ãç¨âì ¨¤¥â¨ä¨ª â®à ¦ ⮩ ª®¯ª¨ |
mcall |
mcall 17 ; get button id |
shr eax,8 |
jmp testbut |
|
key: |
mov al,2 ; ¯®«ãç¨âì ASCII-ª®¤ ¦ ⮩ ª« ¢¨è¨ |
mcall |
mcall 2 ; get ASCII key code |
shr eax,8 |
mov edi,asci ; ¯¥à¥¢®¤ ASCII ¢ ¨¤¥â¨ä¨ª â®à ª®¯ª¨ |
mov edi, asci ; convert ASCII into button id |
mov ecx,18 |
cld |
repne scasb |
70,12 → 63,11 |
lodsb |
|
testbut: |
cmp eax,1 ; ª®¯ª 1 - § ªàë⨥ ¯à®£à ¬¬ë |
jne noclose |
or eax,-1 |
mcall |
cmp eax, 1 ; button 1 -- exit |
jne noexit |
mcall -1 |
|
noclose: |
noexit: |
cmp eax,2 |
jne no_reset |
call clear_all |
83,7 → 75,7 |
|
no_reset: |
finit |
mov ebx,muuta1 ; ¥à¥¢®¤ ¢ ä®à¬ â FPU |
mov ebx, muuta1 ; convert to FPU format |
mov esi,18 |
call atof |
fstp [trans1] |
349,7 → 341,7 |
cmp [id],1 |
je decimal_entry |
mov ebx,[integer] |
test ebx,0xF0000000 |
test ebx, 0xf0000000 |
jnz no_entry |
mov ebx,eax |
mov eax,[integer] |
393,7 → 385,7 |
cld |
rep movsb |
mov [muuta1],al |
mov edi,muuta1+10 ; 楫®¥ |
mov edi, muuta1+10 ; [] |
mov eax,[integer] |
|
new_to_muuta1: |
406,7 → 398,7 |
dec edi |
cmp edi,muuta1+1 |
jge new_to_muuta1 |
mov edi,muuta1+17 ; ¤à®¡®¥ |
mov edi, muuta1+17 ; {} |
mov eax,[decimal] |
|
new_to_muuta2: |
642,20 → 634,12 |
; ********************************************* |
|
draw_window: |
mcall 12, 1 |
|
mov eax,12 |
mov ebx,1 |
mcall |
mcall 48, 3, sc, sizeof.system_colors |
|
mov eax,48 |
mov ebx,3 |
mov ecx,sc |
mov edx,sizeof.system_colors |
mcall |
mcall 48, 4 |
|
mov eax,48 |
mov ebx,4 |
int 0x40 |
mov ecx, eax |
xor eax,eax |
mov ebx,200 shl 16+256 |
684,32 → 668,43 |
cmp edx,39 |
jbe newbutton |
|
mcall ,199 shl 16+28,49 shl 16+18,2 ; 'C' |
mcall ,220 shl 16+8,7 shl 16+8,3 ; 'dec-bin-hex' |
mcall , <199, 28>, <49, 18>, 2 ; 'C' |
mcall , <220, 8>, < 7, 8>, 3 ; 'dec-bin-hex' |
|
mov eax,4 |
mov ebx,27 shl 16+55 |
|
mov ecx,[sc.work_button_text] |
mov edx,text |
mov esi,33 |
newline: |
mcall |
add ebx,20 |
add edx,33 |
mov edi, 55 - 20 |
next_line: |
inc edx |
and edi, 0x0000ffff |
add edi, 20 SHL 16 + 20 |
next_button: |
movzx esi, byte[edx - 1] |
imul eax, esi, 6 |
neg eax |
add eax, 29 |
shr eax, 1 |
shl eax, 16 |
mov ebx, edi |
add ebx, eax |
mcall 4 |
add edx, esi |
inc edx |
add edi, 30 SHL 16 |
cmp [edx - 1], byte 0 |
jne next_button |
cmp [edx],byte 'x' |
jne newline |
jne next_line |
|
call print_display |
|
mov eax,12 |
mov ebx,2 |
mcall |
|
mcall 12, 2 |
ret |
|
print_display: |
pusha |
mcall 13,18 shl 16+210,19 shl 16+13,0xffffff |
mcall 13, <19, 209>, <19, 13>, 0xffffff |
|
mov eax,4 |
mov ebx,135 shl 16+7 |
730,11 → 725,7 |
|
cmp [dsign],byte '+' |
je positive |
mov ebx,23 shl 16+22 |
mov ecx,0x0 |
mov edx,dsign |
mov esi,1 |
mcall |
mcall , <23, 22>, 0, dsign, 1 |
|
positive: |
cmp [display_type],0 |
742,45 → 733,19 |
cmp [decimal],0 |
je whole |
|
mov ebx,180 shl 16+22 |
mov ecx,0x0 |
mov edx,dot |
mov esi,1 |
mcall |
mcall , <180, 22>, 0, dot, 1 |
mcall 47, <10, 0>, [integer], <120, 22>, 0 |
mcall , <6, 0>, [decimal], <187, 22>, 0 |
|
mov eax,47 |
mov ebx,10 shl 16 |
mov ecx,[integer] |
mov edx,120 shl 16+22 |
mov esi,0x0 |
mcall |
|
mov ebx,6 shl 16 |
mov ecx,[decimal] |
mov edx,187 shl 16+22 |
mov esi,0x0 |
mcall |
|
popa |
ret |
|
whole: |
mov ebx,220 shl 16+22 |
mov ecx,0x0 |
mov edx,dot |
mov esi,1 |
mcall |
mcall , <220, 22>, 0, dot, 1 |
|
cmp [integer],0 |
je null |
|
mov eax,47 |
mov ebx,10 shl 16 |
mov ecx,[integer] |
mov edx,160 shl 16+22 |
mov esi,0x0 |
mcall |
|
mcall 47, <10, 0>, [integer], <160, 22>, 0 |
popa |
ret |
|
789,14 → 754,7 |
jne no_display_hexadecimal |
cmp [integer],0 |
je null |
|
mov eax,47 |
mov ebx,256+8 shl 16 |
mov ecx,[integer] |
mov edx,173 shl 16+22 |
mov esi,0x0 |
mcall |
|
mcall 47, <8, 256>, [integer], <173, 22>, 0 |
popa |
ret |
|
803,25 → 761,12 |
no_display_hexadecimal: |
cmp [integer],0 |
je null |
|
mov eax,47 |
mov ebx,2*256+32 shl 16 |
mov ecx,[integer] |
mov edx,32 shl 16+22 |
mov esi,0x0 |
mcall |
|
mcall 47, <32, 2*256>, [integer], <32, 22>, 0 |
popa |
ret |
|
null: |
mov eax,47 |
mov ebx,1 shl 16 |
mov ecx,0 |
mov edx,214 shl 16+22 |
mov esi,0x0 |
mcall |
|
mcall 47, <1, 0>, 0, <214, 22>, 0 |
popa |
ret |
|
849,7 → 794,7 |
|
;data |
|
title db appname,version,0 |
title db 'Calc 1.33', 0 |
|
display_type dd 0 ; 0 = decimal, 1 = hexadecimal, 2= binary |
entry_multiplier dd 10 |
863,16 → 808,16 |
ten dd 10.0,0 |
tmp dw 1,0 |
sign db 1,0 |
tmp2 dq 0x0,0 |
exp dd 0x0,0 |
tmp2 dq 0, 0 |
exp dd 0, 0 |
new_dec dd 100000,0 |
id db 0x0,0 |
id db 0, 0 |
res dd 0 |
trans1 dq 0 |
trans2 dq 0 |
controlWord dw 1 |
smallValueForRounding dq 0.0000005 ; 1/2 from last significant digit |
multipl: dd 10,16,2 |
multipl dd 10,16,2 |
|
dsign: |
muuta1 db '+0000000000.000000' |
880,11 → 825,11 |
muuta0 db '+0000000000.000000' |
|
text: |
db ' A B C D E F C ' |
db ' 1 2 3 + Int Sin Asin' |
db ' 4 5 6 - 1/x Cos Acos' |
db ' 7 8 9 / x^2 Tan Atan' |
db '+/- 0 . * Sqr Pi = ' |
db 1,'A', 1,'B', 1,'C', 1,'D', 1,'E', 1,'F', 3,'CLR', 0 |
db 1,'1', 1,'2', 1,'3', 1,'+', 3,'Int', 3,'Sin', 4,'Asin', 0 |
db 1,'4', 1,'5', 1,'6', 1,'-', 3,'1/x', 3,'Cos', 4,'Acos', 0 |
db 1,'7', 1,'8', 1,'9', 1,'/', 3,'x^2', 3,'Tan', 4,'Atan', 0 |
db 3,'+/-', 1,'0', 1,'.', 1,'*', 3,'Sqr', 2,'Pi', 1,'=', 0 |
db 'x' |
|
asci: db 49,50,51,52,53,54,55,56,57,48,43,61,45,42,47,44,46,27 |
893,3 → 838,5 |
I_END: |
|
sc system_colors |
rb 0x200 ; stack |
E_END: |