align button captions in proper way, finally

git-svn-id: svn://kolibrios.org@3625 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Ivan Baravy 2013-06-08 11:35:43 +00:00
parent b419853b1e
commit f2ab5a6e90

View File

@ -16,32 +16,27 @@
;; 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
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 @@ START:
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 @@ START:
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 @@ START:
no_reset:
finit
mov ebx,muuta1 ; <20>¥à¥¢®¤ ¢ ä®à¬ â FPU
mov ebx, muuta1 ; convert to FPU format
mov esi, 18
call atof
fstp [trans1]
@ -349,7 +341,7 @@ number_entry:
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 @@ number_entry:
cld
rep movsb
mov [muuta1], al
mov edi,muuta1+10 ; 楫®¥
mov edi, muuta1+10 ; []
mov eax, [integer]
new_to_muuta1:
@ -406,7 +398,7 @@ number_entry:
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 @@ atof_convertFractionalPart:
; *********************************************
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 @@ draw_window:
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 @@ print_display:
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 @@ positive:
cmp [decimal], 0
je whole
mov ebx,180 shl 16+22
mov ecx,0x0
mov edx,dot
mov esi,1
mcall
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
mcall , <180, 22>, 0, dot, 1
mcall 47, <10, 0>, [integer], <120, 22>, 0
mcall , <6, 0>, [decimal], <187, 22>, 0
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,39 +754,19 @@ whole:
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
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 @@ clear_all:
;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 @@ kymppi dd 10
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 @@ muuta2 db '+0000000000.000000'
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 @@ butid: db 12,13,14,19,20,21,26,27,28,34,15,39,22,36,29,35,35,1
I_END:
sc system_colors
rb 0x200 ; stack
E_END: