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